srhino Posted September 12, 2013 Share Posted September 12, 2013 I am new and trying to figure out a way to take my records from the data base and display 4 to a row instead of just one record at a time... Here is the code I am working with. $query = "select * from products"; $result = mysql_query($query); echo "<table width=\"100%\" border=\"0\" align=\"center\">\n"; while($row=mysql_fetch_array($result, MYSQL_ASSOC)) { $prodid = $row['prodid']; $description = $row['description']; $price = $row['price']; $quantity = $row['quantity']; echo "<tr><td align = \"center\">\n"; echo "<tr><td><img src=\"showimage.php?id=$prodid\" width=\"80\" height = \"80\">\n</br>"; echo "<a href=\"updatecart.inc.php?id=$prodid\"> $description </a>" ; echo "</td></tr>\n"; } echo "</table>\n"; ?> I thank you in advance for your help. Quote Link to comment Share on other sites More sharing options...
vinny42 Posted September 12, 2013 Share Posted September 12, 2013 So you are wondering how to make the </tr> tag appear only once every four records? How about a variable that counts to four? :-) Quote Link to comment Share on other sites More sharing options...
srhino Posted September 12, 2013 Author Share Posted September 12, 2013 Yeah I assume that would be the correct way...I just don't know how to do that... I want 4 records to show on one TR and then 4 more on the next TR and so on... How would I make a variable out of the incoming rows? Quote Link to comment Share on other sites More sharing options...
Solution mikosiko Posted September 12, 2013 Solution Share Posted September 12, 2013 Did you look on the Sticky folders ?... per example: http://forums.phpfreaks.com/forum/32-faqcode-snippet-repository/ or make a search? this topic has been discussed many...many times before and several times solutions has been posted. Quote Link to comment Share on other sites More sharing options...
srhino Posted September 12, 2013 Author Share Posted September 12, 2013 Thanks...I will look there! 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.