php - Sql Query not returning array results in model? -


in scrolling feed model i'm returning number of users in database , , last 50 users added database in ascending order. reason , last 50 users not returning.
model code following:

<?php  //display total records in db   //add html echo '<link rel="stylesheet" href="assets/css/feed.css" /><div id="feed"<marquee> <b>available accounts: </b>';  //fetch amount of users $usercount="select user_name store"; if ($res=mysqli_query($conn,$usercount))   {   // return number of rows in result set   $rowcount=mysqli_num_rows($res);   printf("%d",$rowcount);   // free result set   mysqli_free_result($res);   }    //add html   echo    '<b>' .    ' . . . last 50 added usernames . . .</b>'; //last 50 added database $lastusers = mysqli_query   ("select user_name (   select *    store    order user_id desc   limit 50 ) store order user_id asc");  $row = mysqli_fetch_array($lastusers); echo $row['user_name'];  echo '</marquee></div>';   ?> 

try out!

<?php   //mysqli information  $db_host     = "localhost"; $db_username = "username"; $db_password = "password";  //connect mysqli database (host/username/password) $connection = mysqli_connect($db_host, $db_username, $db_password) or die("error " . mysqli_error());  //select mysqli dabatase table $db = mysqli_select_db($connection, "table") or die("error " . mysqli_error());   //fetch amount of users $usercount = mysqli_query($connection, "select user_name store"); $rows      = mysqli_num_rows($usercount); echo $rows . " users!" . "<br>";   //last 50 added database $row = mysqli_query($connection, "select * store limit 50");  while ($lastusers = mysqli_fetch_array($row)) {     echo $lastusers['user_name'] . "<br>"; } 

tested , works fine, here example! enter image description here

good luck!


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -