0
$sql = "SELECT images.id, title, image, note 
        FROM news 
        INNER JOIN images ON news.id = images.id_news
        WHERE news.id=?
        ORDER BY images.id DESC";

$stmt = $db->prepare($sql);
$stmt->execute(array($_GET['id']));

$e = $stmt->fetch();

foreach($e[] as $row)
{
    $e[]=array(
        'title'=>$row['title'],
        'image'=>$row['image'],
        'note'=>$row['note']
        );
}

そして、私は持っています

Warning: Illegal string offset 'title' in C:\xampp\htdocs\Wazup.mn\inc\functions.inc.php on line 20

Warning: Illegal string offset 'image' in C:\xampp\htdocs\Wazup.mn\inc\functions.inc.php on line 21

Warning: Illegal string offset 'note' in C:\xampp\htdocs\Wazup.mn\inc\functions.inc.php on line 22
4

2 に答える 2

0

文中[]foreachを省略します

foreach($e as $key => $val)
{
    $key=$val
}

しかし、さらに簡単に、次のことができます

extract($e);
于 2013-09-12T12:31:58.373 に答える