organize pages 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
fariquzeli
Forum Contributor
Posts: 144
Joined: Mon Jun 24, 2002 9:16 am
Location: Chicago
Contact:

organize pages by date

Post 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?
User avatar
m@ndio
Forum Regular
Posts: 163
Joined: Fri Jun 06, 2003 12:09 pm
Location: UK

Post 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.
fariquzeli
Forum Contributor
Posts: 144
Joined: Mon Jun 24, 2002 9:16 am
Location: Chicago
Contact:

Post 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?
User avatar
m@ndio
Forum Regular
Posts: 163
Joined: Fri Jun 06, 2003 12:09 pm
Location: UK

Post 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... :oops:
fariquzeli
Forum Contributor
Posts: 144
Joined: Mon Jun 24, 2002 9:16 am
Location: Chicago
Contact:

Post 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?
User avatar
m@ndio
Forum Regular
Posts: 163
Joined: Fri Jun 06, 2003 12:09 pm
Location: UK

Post by m@ndio »

I see what you mean now.. :o
User avatar
m@ndio
Forum Regular
Posts: 163
Joined: Fri Jun 06, 2003 12:09 pm
Location: UK

Post 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..
fariquzeli
Forum Contributor
Posts: 144
Joined: Mon Jun 24, 2002 9:16 am
Location: Chicago
Contact:

Post 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!
User avatar
m@ndio
Forum Regular
Posts: 163
Joined: Fri Jun 06, 2003 12:09 pm
Location: UK

Post by m@ndio »

did my last post not work?
fariquzeli
Forum Contributor
Posts: 144
Joined: Mon Jun 24, 2002 9:16 am
Location: Chicago
Contact:

Post by fariquzeli »

I found the contribution just before looking, I didn't try your above code.
Post Reply