简体   繁体   中英

Mysqli query not displaying any result set

I have he below code. My issue is if I echo the mysqli_num_rows() it shows me 2 meaning it has 2 rows the query is returning. However for some reason I can not get any of the variables from any of the columns to show on the page.

There are no errors in console or anything; just blank screen?

My code

    $blogsql = mysqli_query($con, "SELECT image AS blogimage, url_key, short_description, publish_date FROM mageplaza_blog_post 
                               where enabled = 1 order by publish_date desc LIMIT $start, $limit");
    $rowsnummber = mysqli_num_rows($blogsql);
    //echo "$rowsnummber<br />";
   // die();

    while($row = mysqli_fetch_assoc($blogsql))
     {
         echo $row['blogimage'] . 'hh<br />';
     }
?>

So the above is not even showing the hh ??

mysqli_fetch_array returns a numerically indexed array so extract would not produce the variables with your column names.

For your purpose you can replace it with mysqli_fetch_assoc .

Try this:

while($row = mysqli_fetch_assoc($blogsql)){
    echo $row['url_key'] . '<br />';
}

reference: http://php.net/manual/en/mysqli-result.fetch-assoc.php

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM