Snatchio Posted April 21, 2009 Share Posted April 21, 2009 I am having an issue creating a listing of names. Currently people can sign up but then when you look at who signed up it only lists that last person who signed up and not everyone in the list. When I test it in Dreamweaver it seems to work correctly but when it is live I am having the issue. Here is the code... <?php mysql_select_db($database_Bunker, $Bunker); $query_Recordset1 = "SELECT element_1_1, element_1_2 FROM ap_form_1 ORDER BY element_1_1 ASC"; $Recordset1 = mysql_query($query_Recordset1, $Bunker) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); ?> Then in the body... <table border='0' align="center" cellpadding='0' cellspacing='0'> <tr> <th> <form> <?php echo $row_Recordset1['element_1_1']; ?> <?php echo $row_Recordset1['element_1_2']; ?> </form> </th> </tr> </table> Can anyone please assist? Quote Link to comment https://forums.phpfreaks.com/topic/155068-php-listing-help/ Share on other sites More sharing options...
drbloke Posted April 21, 2009 Share Posted April 21, 2009 The results are returned as an array and you need to loop through the array. Something like this in the body: <table border='0' align="center" cellpadding='0' cellspacing='0'> <?php while ($row = mysql_fetch_assoc($Recordset1)) { echo "<tr><td>".$row_Recordset1['element_1_1']."</td><td>".$row_Recordset1['element_1_2']."</td></tr>\n"; } ?> </table> Quote Link to comment https://forums.phpfreaks.com/topic/155068-php-listing-help/#findComment-815631 Share on other sites More sharing options...
Snatchio Posted April 21, 2009 Author Share Posted April 21, 2009 Thanks for the code. However, in using it the results repeat the first result 7 times. Which is odd that it stops at 7 and does not continue. The current database contains names to be listed. Quote Link to comment https://forums.phpfreaks.com/topic/155068-php-listing-help/#findComment-815741 Share on other sites More sharing options...
premiso Posted April 21, 2009 Share Posted April 21, 2009 <table border='0' align="center" cellpadding='0' cellspacing='0'> <?php while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)) { echo "<tr><td>".$row_Recordset1['element_1_1']."</td><td>".$row_Recordset1['element_1_2']."</td></tr>\n"; } ?> </table> Small edit in the while loop. Instead of $row switched to $row_Recordset1 Quote Link to comment https://forums.phpfreaks.com/topic/155068-php-listing-help/#findComment-815748 Share on other sites More sharing options...
Snatchio Posted April 22, 2009 Author Share Posted April 22, 2009 Thanks Premiso... it works great. Quote Link to comment https://forums.phpfreaks.com/topic/155068-php-listing-help/#findComment-816103 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.