Warptweet Posted April 16, 2007 Share Posted April 16, 2007 I use this code to make a table with two rows, and four columns, all together. <tr> <td>top</td> <td>top</td> <td>top</td> <td>top</td> </tr> <tr> <td>bottom</td> <td>bottom</td> <td>bottom</td> <td>bottom</td> </tr> How would I make it so that for each column, it displays one of the 4 most recent rows in my database? The most recent rows in my database can be determined because the row with the highest id (AUTO_INCREMENT) is the newest one. I need to select the most recent 4, and display the most recent four on those tables. For "top", I need it to display " . $row['upload_preview'] . " and for the "bottom" I need it to display " . $row['upload_name'] . " Any ideas how to accomplish this? Thanks for any help! Link to comment https://forums.phpfreaks.com/topic/47183-tables-next-to-each-other/ Share on other sites More sharing options...
rcorlew Posted April 16, 2007 Share Posted April 16, 2007 $sql = mysql_query("Select * FROM tablename ORDER BY id DESC LIMIT 4"); Link to comment https://forums.phpfreaks.com/topic/47183-tables-next-to-each-other/#findComment-230081 Share on other sites More sharing options...
Warptweet Posted April 16, 2007 Author Share Posted April 16, 2007 I know that of course, but how will the website know that one of the columns needs to display the second most recent row? Third most recent row? Fourth most recent row? Link to comment https://forums.phpfreaks.com/topic/47183-tables-next-to-each-other/#findComment-230083 Share on other sites More sharing options...
rcorlew Posted April 16, 2007 Share Posted April 16, 2007 Thats what the LIMIT 4 is. As long as your id row is set to autoincremint that will work wonders. It will pull the last 4 rows of data which will be the newest 4 rows. Link to comment https://forums.phpfreaks.com/topic/47183-tables-next-to-each-other/#findComment-230086 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.