mysql/php loop by date ...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pepe_lepew1962
Forum Commoner
Posts: 44
Joined: Thu Nov 20, 2008 10:29 am

mysql/php loop by date ...

Post by pepe_lepew1962 »

//
Hello, I am in great need for a loop on a group of records. Basically I need a loop on the date field and pull all those records for that date, then loop onto the next date in the table. If I had 3 records for 04/03/2011, dispaly them, then grab the next date, say 04/06/2011 and display all of those records. It is probably very simple, but not simple enough for me, can anyone help with this please.
//
//
tblTable02.fldName2 // Date Field
//
//
$result = mysql_query('SELECT tblTable01.fldName1, tblTable01.fldName2, tblTable01.fldName3, tblTable02.fldName1, tblTable02.fldName2 FROM tblTable01, tblTable02 WHERE (tblTable01.fldName1 = tblTable02.fldName1) ORDER BY tblTable01.fldName1, tblTable02.fldName2');
//
klandaika
Forum Newbie
Posts: 19
Joined: Wed Mar 30, 2011 3:25 pm
Location: New York

Re: mysql/php loop by date ...

Post by klandaika »

Why don't you just change your sorting order to

Code: Select all

ORDER BY tblTable02.fldName2, tblTable01.fldName1;
This way it will arrange everything by date and then you can just keep looping. if you want to start with specific date then add it to the WHERE clause
Post Reply