newb Posted September 23, 2006 Share Posted September 23, 2006 im having a bit of trouple with the while loop...its probably an easy fix, just cant figure it out atm. [code]<?php$query = $libmysql->query("SELECT * from $table_users ORDER by username ASC");echo "<table width='100%' align='center'> <tr> <td colspan='4' valign='top' id='navcontent'>$links</td> </tr> <tr> <td colspan='4' valign='top'><strong>Member List </strong></td> </tr> <tr> <td valign='top'><strong>Name</strong></td> <td valign='top'><strong>Usergroup</strong></td> <td valign='top'><strong>Registration Date </strong></td> <td valign='top'><strong>Email</strong></td> </tr>";while ($row = $libmysql->fetch_array($query)) {$i++;$user = $row['username'];$signup_date = $row['signup_date'];$email = $row['email'];$tempsid = $row['sid'];$query = $libmysql->query("SELECT * FROM $table_usergroups WHERE id = '$tempsid'");$row = $libmysql->fetch_array($query);$custom_title = $row['custom_title'];$libmysql->free_result($query);echo "<tr><td width='35%' valign='top'>$user</td><td width='60%' valign='top'>$custom_title</td><td width='60%' valign='top'>$signup_date</td><td width='60%' valign='top'>$email</td> </tr>"; if ( $i == 2 ) { echo "<tr><td width='35%' valign='top'>$user</td><td width='60%' valign='top'>$custom_title</td><td width='60%' valign='top'>$signup_date</td><td width='60%' valign='top'>$email</td>"; $i = NULL; } echo '</tr></table>'; }?>[/code]any suggestions? Link to comment https://forums.phpfreaks.com/topic/21801-while-loop-not-echoing-multiple-resultsrepeating-itself/ Share on other sites More sharing options...
Orio Posted September 23, 2006 Share Posted September 23, 2006 Before the loop, add- $i=1.And instead of writing $i=NULL (in the end of the loop), write $i=1.Orio. Link to comment https://forums.phpfreaks.com/topic/21801-while-loop-not-echoing-multiple-resultsrepeating-itself/#findComment-97362 Share on other sites More sharing options...
newb Posted September 23, 2006 Author Share Posted September 23, 2006 ok it echo's multiple tables but in each of the tables it repeats the same information....ie:John Doe - [email protected]John Doe - [email protected]instead of :John Doe - [email protected]Other John Doe - [email protected] Link to comment https://forums.phpfreaks.com/topic/21801-while-loop-not-echoing-multiple-resultsrepeating-itself/#findComment-97365 Share on other sites More sharing options...
Orio Posted September 23, 2006 Share Posted September 23, 2006 That's probbly because $libmysql->fetch_array() doesnt move the internal pointer.Why dont you use mysql_fetch_array($query) ?Orio. Link to comment https://forums.phpfreaks.com/topic/21801-while-loop-not-echoing-multiple-resultsrepeating-itself/#findComment-97366 Share on other sites More sharing options...
newb Posted September 23, 2006 Author Share Posted September 23, 2006 i did, same effect. $libmysql->fetch_array is just a function i defined. Link to comment https://forums.phpfreaks.com/topic/21801-while-loop-not-echoing-multiple-resultsrepeating-itself/#findComment-97367 Share on other sites More sharing options...
newb Posted September 23, 2006 Author Share Posted September 23, 2006 ok got it working thanks. Link to comment https://forums.phpfreaks.com/topic/21801-while-loop-not-echoing-multiple-resultsrepeating-itself/#findComment-97376 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.