I have a database that is keeping track of 50 images. I want to display the images so that there are 10 rows of 5 images per row. So for example: Row 1 : IMG1 IMG2 IMG3 IMG4 IMG5 Row 2 : IMG6 IMG7 IMG8 IMG9 IMG10 and so on. The issue is they have a field that tracks how many times they have been viewed and need to be displayed in order of most views to least. So when I tried using the LIMIT 0, 5 LIMIT 6, 5 and so on, it only ordered those results insted of all of the images in the datase. Thanks for the help.
1. Try limit 0,5 limit 5,10 and etc 2. Make one sql-query that selects ALL images and then use `for` to display images in ROWS
I dont know what you mean by for and I mentioned that the 0,5 limit does not work for this situation. Thanks though.
<? ... echo "<table><tr>"; $res=sql("select * from table order by field desc;"); for ($i=0;$i<mysql_num_rows($res);$i++){ if ($i%5==0&&$i>0) echo "</tr>\n<tr>"; $name=mysql_result($res,$i,'name'); echo "<td>$name $i</td>"; } echo "</table>"; ... PHP:
Why do you want to limit them? Try selecting them all and ordering them by views. Then have a loop within a loop to display them in a table with 5 cells per row. I have had a little too much wine to tell exactly but I believe that is what vdd is saying by way of code.