Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
September 30, 2005, 1:28 am
rate this thread
I am trying to develope my personal site to select from my mysql
database and organize data on the page so that it will display all the
submissions for that day, then break and display the next day, then
break and display the third day, etc...
Should I query the whole database into an array and then sort with php?
Example: SELECT * FROM pictures
Or should I (and I would prefer) query an array with the dates I need?
Example: SELECT * FROM pictures WHERE date = $array[$i]
Can you provide an example of how the php script would look? I am
looking for some types of special functions I might be missing from php
Any help will be greatly appreciated.
Re: PHP script SELECT FROM mysql database WHERE date
second you'd have to query the database once for each date you want to
show. I'd recommend this instead;
SELECT * FROM pictures ORDER BY date
You will be able to get all the data you need in only one query. The
script would basically look like this.
//Assuming you already opened and selected the db...
$query = "SELECT * FROM pictures ORDER BY date";
$result = mysql_query ($query);
while (($number_of_items < 30) && ($row = mysql_fetch_array($result)))
if ($last_date != $row['date'])
$last_date = $row['date'];
Hope I helped and all =)