无法从多个mysqli查询中获取数组resut

时间:2015-05-13 14:30:23

标签: php mysql mysqli

我'尝试按照http://www.w3schools.com/php/func_mysqli_multi_query.asp

中的描述获取多个SQL查询

然而,根据我尝试的代码,我没有得到结果

代码

    $cid ="142"; //$_POST['albumId'];

    // Thumbnail Listing

//  if(isset($_POST['albumId'] ))   {

        $number_of_thumbs_in_row = 5;

        $sql = "SELECT album_name FROM albums WHERE albumId='$cid';";
        $sql .= "SELECT * FROM `photos` WHERE `album_id`= '$cid';";
        $sql .= "SELECT * FROM `thumbs` WHERE `album_id`= '$cid';";


    if(mysqli_multi_query($mysqli,$sql)) {
  do
    {
    // Store first result set
    if ($result=mysqli_store_result($mysqli))
      {
      while ($row=mysqli_fetch_row($result))
        {
                $row_array['albumName'] = $row['album_name'];

                $row_array['photoId'] = $row['photoid'];
                $row_array['photoName'] = $row['photo_name'];
                $row_array['photoUrl'] = $row['photo_url']; 

                $row_array['thumbId'] = $row['thumbId'];
                $row_array['thumbName'] = $row['thumb_name'];
                $row_array['thumbnailUrl'] = $row['thumbnail_url'];

                array_push($return_array,$row_array);   
        }
      mysqli_free_result($mysqli);
      }
    }
  while (mysqli_next_result($mysqli));
}

我'认为错误是我如何得到$ row数据,但不完全确定。任何人都可以帮忙吗

0 个答案:

没有答案