hello I want to print "title" in the menu content data in the database, but I get an error. I do not know much about json, but as a result of my research, something like this came out and the error code is below
Warning: Illegal string offset 'title' in menu.php on line 59
mysql database data menu_content
[{"title":"HelloWord","address":"HelloAdres","phone":"HelloPhone","submenu":[{"email":"HelloSubmenuEmail","phone":"HelloSubmenuPhone","fax":"HelloSubmenuFax"}]}]
pdo
$query = $db->prepare('SELECT * FROM menu ORDER BY menu_id DESC');
$query->execute();
$rows = $query->fetchAll(PDO::FETCH_ASSOC);
table
<tbody>
<?php foreach ($rows as $row): ?>
<tr data-id="<?= $row['menu_id'] ?>">
<td width="90"><?= $row['menu_id'] ?></td>
<td width="90"><?= $row['menu_title'] ?></td>
<td><?php json_decode($row['menu_content']['title'],true) ?></td>
<td><?= $row['menu_date'] ?></td>
</tr>
<?php endforeach; ?>
</tbody>
$row['menu_content']has the JSON, nottitle. Also return that to a variable, otherwise it won't do anything for you.