PHP: $number == "1"; while($a_row = mysql_fetch_object($query)) { while($number < ($result + 1)) { if($a_row->number == $number) { ?> <tr> <td width="4%"><?PHP print $a_row->number ?></td> <td width="24%" bgcolor="#3366CC"><a href="<?PHP print $a_row->website ?>" target="NEW"><?PHP print $a_row->name ?></td> <td width="5%" bgcolor="#6699cc"><?PHP print $a_row->age ?></td> <td width="13%" bgcolor="#3366CC"><a href="mailto:<?PHP print $a_row->email ?>">Email <?PHP print $a_row->name ?></td> <td width="20%" bgcolor="#6699cc"><?PHP print $a_row->location ?></td> <td width="32%" bgcolor="#3366CC"><?PHP print $a_row->interests ?></td> </tr> <?PHP } $number = $number + 1; } } print "</table>"; I have been pouring over this for hours now and i cannot see why it wont list everything in my database. In the DB they are numbered starting from 1, but when i run this code, if it works atall it will only print the first entry. Any ideas why it isnt working ? thanks, Jaffer
that's to do with your $number variable being 1. It needs to be as big as the amount of rows in your table. mysql_num_rows($result) will return this for you from your query. try PHP: $number - mysql_num_rows($query);
but the number neds to start oin one, cause in my table, there is a number column, where all the users are numbered. I then compare the number to the row, then use that row. It needs to start at 1 and increase by 1 everytime. unless i have misunderstood what you are saying!
personally i'd go with - PHP: $a_row = mysql_fetch_object($query); $number = mysql_num_rows($query); $number1 = "1"; while ($number >= $number1) { echo (" <tr> <td width=\"4%\">$a_row->number</td> <td width=\"24%\" bgcolor=\"#3366CC\"><a href=\"$a_row->website\" target=\"NEW\">$a_row->name</td> <td width=\"5%\" bgcolor=\"#6699cc\">$a_row->age</td> <td width=\"13%\" bgcolor=\"#3366CC\"><a href=\"mailto:$a_row->email\">Email $a_row->name</td> <td width=\"20%\" bgcolor=\"#6699cc\">$a_row->location</td> <td width=\"32%\" bgcolor=\"#3366CC\">$a_row->interests</td> </tr> "); $number1++; }
that didnt work either, its being vry funny so i just stole me some code form another one of my database things i made. I have no idea to this time what the heck was going on thanks for your help though
I've never used a function to call stuff from a db, was kinda guess work I usually do it the long way and use $row = mysql_query($query) $something = $row['something']; etc