Portal Home > Knowledgebase > Articles Database > PHP and DB calling query help


PHP and DB calling query help




Posted by kayz, 08-20-2007, 10:22 AM
Hi all, i have a long table set up, each row represents data for each day. The data is static not dynamic, so i would want row 1 to show on Monday, row 2 on Tuesday etc, until the end of the month. I have a website full of tables and i am displaying data on each main page, the data is only of a certain date. Now to save myself time, is there any way i can store all the information on the database and then get it to call the data for that certain day and display it on the page i want it to? Then after that day is over, when it hits 12am the next days data is displayed. I am not entirely a noob, i have some knowledge of php and MySQL. Any help is much appreciated. Thanks in advance,

Posted by Steve_Arm, 08-20-2007, 11:44 AM
One solution would be to add a field to the database that holds the day for the data and then by checking the day you will call the query or much faster something like that: Of course the day filed would be Mon,Tue and so on. Another solution since your data are static is to write them to a file as an PHP array and read the file, showing the correct item. The array for the 2nd example would be You can create it and serialize it before writing it to the file.

Posted by juangake, 08-21-2007, 06:17 AM
You want to learn the *timestamp* data type for MySQL and *time functions*, that would be an efficient and convenient way to do date/time-based queries

Posted by kayz, 08-21-2007, 06:59 AM
Can anybody show me a tutorial or tell me what im trying to do is called? How will i be able to use time/date to show specific data which is already stored or can be called from a php file? Cheers.

Posted by Steve_Arm, 08-21-2007, 07:08 AM
I don't know if my examples have helped you, but if you have the data on a file post the file to see it.

Posted by kayz, 08-21-2007, 08:56 AM
Steve i understand your example, but will bump into a small problem im sure. Ok Steve my table will hold these fields: id coloumn: auto integer (will hold numbers from 1 - x) Sept/Oct: Integer (will hold days like 21/22/23) Day: Text (will hold Mon-Sun) Time 1: Integer (Will hold Time) Time 2: Integer (Will hold Time) Time 3: Integer (Will hold Time) Time 4: Integer (Will hold Time) Time 5: Integer (Will hold Time) They will be displayed in coloumns, and i will need to grab the information horizontally from across the table, so all the fields will be included. I would like each row to display starting a certain date. Does this seem correct so far? Now im worried on how i will be able to fix another problem if i get it all setup. I live in the UK and the dates and times are for the population living here in the UK. The server it is being hosted on is in the US, what will i need to do to configure the database and the scripts that i use to sync with UK time? Cheers Thanks!

Posted by Steve_Arm, 08-21-2007, 10:17 AM
Your table is a bit confusing. Let's clarify something first. You will display data for each day of the week - each day of the month or for each day of the year? Where will the data start over again?

Posted by kayz, 08-21-2007, 01:10 PM
no its only for a one month period. It will display data for each day for just one month starting in a few weeks time.

Posted by Steve_Arm, 08-21-2007, 01:19 PM
Wouldn't this table be appropriate? ID : auto increment (int) date: (date) -- the date for which data will be displayed/queried text: text to show For displaying correct time read this: http://www.informit.com/articles/art...&seqNum=4&rl=1

Posted by kayz, 08-22-2007, 05:42 AM
thats right, but the date field will need to be text i believe as i will be entering the date manually which will be different for each day. It will be displaying different dates and not the actuall date of the day. I will need several "text" fields also as there is more than one coloumn, each coloumn will hold different sets of data. I hope im on the right track.



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
Hitreg Issues (Views: 838)
icebluehost Review (Views: 790)


Language:

LoadingRetrieving latest tweet...

Back to Top Copyright © 2018 DC International LLC. - All Rights Reserved.