phenom18 Posted July 3, 2008 Share Posted July 3, 2008 hello ! i'm fairly new to php and sql so would greatly appreciate if anyone could help me with this. what i want to do is to get different users to enter a single field say their name through a form and then display it in the following format name 1 name 2 name 3 name 4 name 5 name 6 name 7 name 8 name 9 name 10 name 11 ............so on no. of rows is no limit. here's the code but its not working while ( $row = mysql_fetch_assoc($result) ) { echo("<tr>"); $ctr=1; if($ctr<6) { echo("<td>"); echo($row["name"]); echo("</td>"); $ctr++; } echo("</tr>"); // end the row } Quote Link to comment https://forums.phpfreaks.com/topic/113107-help-with-displaying-mysql-query-in-html-columns/ Share on other sites More sharing options...
rajivgonsalves Posted July 3, 2008 Share Posted July 3, 2008 your code should be something like the following $ctr=1; echo "<tr>"; while ( $row = mysql_fetch_assoc($result) ) { if (($ctr%6)==0) {echo "</tr><tr>";} echo "<td>"; echo $row["name"]; echo "</td>"; $ctr++; } echo("</tr>"); // end the row hope its helpful Quote Link to comment https://forums.phpfreaks.com/topic/113107-help-with-displaying-mysql-query-in-html-columns/#findComment-581031 Share on other sites More sharing options...
phenom18 Posted July 3, 2008 Author Share Posted July 3, 2008 thankkk u very muchh....that worked just fine.....!!!! Quote Link to comment https://forums.phpfreaks.com/topic/113107-help-with-displaying-mysql-query-in-html-columns/#findComment-581152 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.