PDA

View Full Version : PHP question


truelight
12-15-2000, 10:02 AM
Hi, fellow geeks - I need your help.

I'm currently using a MySQL driven download system for my site. Now, I want it to display the three newest files on my front page.

The files in the script are not dated, but they are given a "DownloadID" in the MySQL database. So, the easiest thing to do here would be to have it display the files with the 3 highest DownloadID:s, right?

But how does one do that? I'm new to PHP, so I would kill for a bit of help here, please! http://geekvillage.com/ubb/smile.gif

JDF000
12-15-2000, 01:23 PM
Hmm, thought I had it all figured out, but I can't figure out how you would code it off the top of my head. The logic is to fetch the download id's and put them into an array, then count the elements in the array, and loop through the last 3 using the decrement operator but I'm having trouble figuring out how you would code it, easy as it may seem.

[This message has been edited by JDF000 (edited 12-15-2000).]

Lavee
12-15-2000, 06:49 PM
Hi truelight,

I am learning PHP / Mysql too. Let me know if this will resolve your issue.

$sql = "SELECT * FROM yourtablename ORDER BY DownloadId DESC LIMIT 3;

Your latest 3 elements will be stored in $sql
as an array.

Thanks

Lavee

------------------
Free Stuff Directory
www.Lavee.com (http://www.Lavee.com)
Are You In TheTopList.Com (http://www.TheTopList.com)
Webmasters - Add your site to thetoplist and get moretraffic

Click Here!