Page 1 of 1
organize pages by date
Posted: Thu Jul 03, 2003 2:35 pm
by fariquzeli
I have a column date in my orders table, and i want to make a setup that will allow me to browse my orders by date. The dates are put into the database in this format: 2003-07-03 14:39:42
How would I setup a hyperlink to grab all entries from the third of july of this year from the database and display them all on a database?
Posted: Thu Jul 03, 2003 3:22 pm
by m@ndio
at the end of your SQL query put ORDER BY orders DESC orders, being the name of the column you wish to sort.
Posted: Thu Jul 03, 2003 3:26 pm
by fariquzeli
I understand that much what I want is to have is the amount of invoices from the day on the page
what kind of sql query would I put for that?
My order admin would look like this:
07-03-2003 - click for orders from this day
07-04-2003 - click for orders from this day
07-04-2003 - click for orders from this day
etc.etc.
How would I make a date somehow pass across pages to grab the invoices from that day when the date is formatted as mentioned above? I know how to get the orders sorted, but I need to know hwo to sort them by the day. any ideas on that?
Posted: Thu Jul 03, 2003 3:53 pm
by m@ndio
can you not just do something like this:
SELECT * from orders_table WHERE date = ' $order_date ' ORDER BY date DESC
?
Am I missing the point? Please forgive me if I am...

Posted: Thu Jul 03, 2003 4:07 pm
by fariquzeli
This does kinda work, I get no records from the db when I put in a date like 2003-07-03 because that column formats thing with the 24h timestamp as well
is there a way to just try grab the date and year rather than the rest of the time info in that column?
Code: Select all
<?php
$query_OrderDisplay = "SELECT * FROM orders WHERE date_purchased='$order_date' ORDER BY date_purchased DESC";
?>
that's the query and the query is good, its just that it returns no results when I type in
page.php?date_purchased=2003-07-03 because the actual column contents are formatted as such: 2003-07-03 14:22:52
is there anyway to workaround that?
Posted: Thu Jul 03, 2003 4:15 pm
by m@ndio
I see what you mean now..

Posted: Thu Jul 03, 2003 4:20 pm
by m@ndio
errm what about a like statement:
Code: Select all
$query_OrderDisplay = "SELECT * FROM orders WHERE date_purchased LIKE '%$order_date%' ORDER BY date_purchased DESC";
This is not ideal I know but you should not hit any problems with this... In theory it should look in the DB and find the records where something like "2003-07-03" appears..
Posted: Thu Jul 03, 2003 4:43 pm
by fariquzeli
Thanks alot, I looked around the net and found a contribution that allowed to do batch printing per day (looks like they just barely beat me to it)
I installed it and it is working properly, thanks for your help though!
Posted: Thu Jul 03, 2003 5:02 pm
by m@ndio
did my last post not work?
Posted: Thu Jul 03, 2003 5:30 pm
by fariquzeli
I found the contribution just before looking, I didn't try your above code.