datafan Posted September 5, 2007 Share Posted September 5, 2007 Here is the website, www.goodstylist.com I am refering to the three pictures of "Todays Top Rated Stylists". what I am trying to do is figure out a clean way to start a new table row for each 3 Stylists. So if I change my query to pull 12 instead of just 3, the output on the screen will just loop creating rows of 3 like the one there. Here is what is driving it now: $query = sprintf("SELECT username, thpicname1, realname, city, state, currentrate FROM users WHERE(thpicname1 !='') ORDER BY currentrate DESC LIMIT 0,3"); // Perform Query GetMyConnection() or die(mysql_error()); $result = mysql_query($query); if (!$result) { $message = 'Invalid query: ' . mysql_error() . "\n"; $message .= 'Whole query: ' . $query; die($message); } echo "<table cellpadding='4' width='760'>"; echo "<tr>"; while ($row = mysql_fetch_assoc($result)) { $thumb = "files/userimages/" .$row['thpicname1']; echo "<td border='3' width='250'><a href='files/profileview.php?find=".$row['username']."' target='_self'><img src='".$thumb."'></a><br>" .$row['realname']. "<br>" . $row['city'] . " , " . $row['state'] . "<br>Current Rating " . $row['currentrate'] . "</td>"; } mysql_free_result($result); ?> </tr> </table><br> Thanks for any help, and how do you get your code to show up with all the colors here like it does in notepad++ ? Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted September 5, 2007 Share Posted September 5, 2007 Change your while loop to this: <?php $i = 0; while ($row = mysql_fetch_assoc($result)) { $thumb = "files/userimages/" .$row['thpicname1']; if ($i == 3){ echo '<tr>'; $i=0;} echo "<td border='3' width='250'><a href='files/profileview.php?find=".$row['username']."' target='_self'> <img src='".$thumb."'></a><br>" .$row['realname']. "<br>" . $row['city'] . " , " . $row['state'] . " <br>Current Rating " . $row['currentrate'] . "</td>"; $i++; } ?> Quote Link to comment Share on other sites More sharing options...
datafan Posted September 5, 2007 Author Share Posted September 5, 2007 Perfect! Thanks a ton! Quote Link to comment 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.