PDA

View Full Version : need help coding timetable


rehaan
08-29-2009, 05:25 PM
hello

i have been creating a timetable for my dj website.

On the website i have been able to echo the result of the Dj name and the time they will play music.

now my Question is: how to i echo monday, tuesday etc etc automatically.
i mean how do i make it echo for example monday and the next day it changes automattically to tuesday and so on.

structure of timetable database is as follows:

CREATE TABLE IF NOT EXISTS `timetable` (
`id` int(7) NOT NULL auto_increment,
`dj` varchar(40) NOT NULL,
`show` varchar(400) NOT NULL,
`time` varchar(40) NOT NULL,
`date` varchar(40) NOT NULL,
`comments` varchar(400) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;



PLEASE HELP:(

bee80
08-30-2009, 09:22 AM
i would recommend you use a single DATETIME row in your database rather than 2 and name it something like setstarts then use a script like :


$q = sprintf('SELECT * FROM timetable ORDER BY setstarts ASC');
$r = @mysql_query($q);


while($row = @mysql_fetch_array($r)) {

//if datetime is equal to now plus 24 hours
if($row[setstarts] == (now() + 86400)) {
// echo out the results of that row formatted how u like
echo 'DJ : ' . $row[dj] . ' Show : ' . $row[show] . ' Time : ' $row[time] . '
Comments : ' . $row[comments] ' ;
}
}



something like this would work it might need some playing around with as i think now() is a mysql function

rehaan
08-30-2009, 05:34 PM
thanxs let me try zat

thanxs again

edbr
08-31-2009, 01:47 AM
date() will get it it php i think this will need formatting though

rehaan
09-01-2009, 04:26 AM
i was try the code below but wat i wanted was to insert a table instead of echoing just the days is that possible ??

<?php
$d=date("D");
if ($d=="Mon")
echo "monday";
elseif ($d=="Tue")
echo "tuesday";
elseif ($d=="Wed")
echo "wednesday";
elseif ($d=="Thu")
echo "thurday";
elseif ($d=="Fri")
echo "friday";
elseif ($d=="Sat")
echo "saturday";
elseif ($d=="Sun")
echo "Sunday!";
?>

edbr
09-01-2009, 04:43 AM
you mean echo a value from your table? yes , you just have to configure your conditions. might want to look at switch also instaed of so mant if elses

rehaan
09-03-2009, 10:15 AM
you mean echo a value from your table? yes , you just have to configure your conditions. might want to look at switch also instaed of so mant if elses

Can u give me an idea of the code Edbr