Page 1 of 1

member list

Posted: Fri Jul 26, 2002 8:21 pm
by cheatboy00
o.k. i'm obivously creating a member list.... and it SHOULD be easy but its not working i'm incompetent ..... help!!

i have this:

Code: Select all

$qry = mysql_query ("SELECT * FROM users ORDER BY id LIMIT 1,20");
$row = array(mysql_fetch_assoc($qry));

for ($i = 0; $i < $rows; $i++)&#123;
   echo "<TR><TD ALIGN=CENTER VALIGN=TOP WIDTH="5%">";
      echo $row&#1111;$i]&#1111;'id'];
   echo "</TD>";

   echo "<TD ALIGN=LEFT VALIGN=TOP>";
      echo $row&#1111;$i]&#1111;'login'];
   echo "</TD>";

   echo "<TD ALIGN=CENTER VALIGN=TOP>";
      echo $row&#1111;$i]&#1111;'date'];
   echo "</TD></TR>";
      
&#125;
as you can see i want to order all the users in users table by their id... so i want 2 arrays....
one for each row... then inside that i want an associative array..

i want to output the first 20 people...

but nothing shows up

Posted: Fri Jul 26, 2002 8:59 pm
by volka
with mysql_fetch_assoc you fetch a single result row as an associative array, so you can access the fields by their db-field-name.
However, the important thing is: you only fetch a single line. So you have to do it as long as there are result-rows remaining. You may do this by a for-loop with mysql_num_rows or even simpler with a while-loop having the result of mysql_fetch_assoc as condition

Code: Select all

$qry = mysql_query ('SELECT * FROM users ORDER BY id LIMIT 1,20') or die('query failed: '.mysql_error());
while($row = mysql_fetch_assoc($qry))
&#123; 
   echo '<TR><TD ALIGN="CENTER" VALIGN="TOP" WIDTH="5%">'; 
      echo $row&#1111;'id']; 
   echo "</TD>"; 

   echo '<TD ALIGN="LEFT" VALIGN="TOP">'; 
      echo $row&#1111;'login']; 
   echo "</TD>"; 

   echo "<TD ALIGN="CENTER" VALIGN="TOP">"; 
      echo $row&#1111;'date']; 
   echo "</TD></TR>"; 
&#125;

Posted: Fri Jul 26, 2002 9:16 pm
by cheatboy00
thanks