Well, basically I'm just using the MAX function to find the newest added file (it will have the highest number). I was wondering if there was some way to pull ALL of the info for that file from the database using just the results of the MAX() search? I've tried the standard method of fetching the row into a variable and pulling the data out of the array with it's named key, but that doesn't seem to work with MAX. Does it just give us back that one result?
eg./ to get the file ID with MAX I did this (as per your suggestion):
$query = "SELECT MAX(file_num) AS NUM FROM " . DBTABLE ;
(...dbconnection stuff here...)
$data=mysql_fetch_array($queryResultHandle);
$file_num = $data["NUM"];
That is what you suggested, and it works well for retrieving the file number. But in order to get the rest of the info on the file (such as file_name, file_pic, file_num_downloads), I have to do another complete query to the database using $file_num as my search key to select * (the whole row).
$newquery = "SELECT * FROM " . DBTABLE . " WHERE file_num = '$file_num'";
Then I do the array thing again as per usual. Is there ANY way to access the other data relating to that file with the original result given by MAX()?
There are actually three files in total I'm trying to retrieve, two of which use the MAX function, and the third will use a random function. I forsee this making at least 4 queries to the database using the above method. Is there some slick method of using the max result to get that info? Or perhaps another way to combine the $file_num, $file_highest_download and $random_file into one query to give me the three separate resultant files? Geez, even I'm getting confused writing this, so I apologize in advance if you get confused reading it!
As it stand right now, it IS doing everything I want it to do, I just wanted to cut down the number of queries if possible.
Many, many thanks! :-)