从单行SQL获取密钥和值

时间:2014-02-04 13:56:36

标签: php mysql

我无法从单行获取密钥和值...

这是我的代码:

$tab_titres_fr=array();
$sql="SELECT * FROM recettes  WHERE recetteid = '$id' ";
$request = mysqli_query($con,$sql);
$row = mysqli_fetch_assoc($request);
$tab_titres_fr[]=json_encode($row);    

foreach($tab_titres_fr as $key => $value) {

    echo   $keys." / ".$value."<br>" ;
}

1 个答案:

答案 0 :(得分:0)

$request = mysqli_query($db,$sql);
while($row = mysqli_fetch_assoc($request)){
$tab_titres_fr[]=json_encode($row);
}
foreach($tab_titres_fr as $key => $value) {

echo   $key." / ".$value."<br>" ;
}