FunkyBlueStick
03-20-2001, 08:05 PM
I'm trying to write a script that uses info from a calendar database and displays the next 7 days events, day by day. I've managed to get it to display the seven days but I can't get it to display the SQL data? Can someone have alook at this script and tell me what you think is wrong?
// Open SQL Connection
$db="udubs";
$table="calendar";
mysql_pconnect("db.clanunwanted.f2s.com","*****","*****")
or die("Could not connect to the database server... Please try later!");
// Loop to display next 7 days
for ($counter=0; $counter<=7; $counter++){
echo ("<font size=-2>".gmdate("D d M Y", mktime(0,0,0, gmdate(m), gmdate(d)+$counter, gmdate(Y)))."</font>");
echo ("<br>");
$date = gmdate("Y-m-d", mktime(0,0,0, gmdate(m), gmdate(d)+$counter, gmdate(Y)));
echo ("<font size=-2>$date</font>");
echo ("<br>");
// Make SQL Query
$sql = "select * from $table where date = $date order by time";
$result = mysql_db_query($db,$sql);
$numrows = mysql_num_rows($result);
if (!$numrows == 0){
echo ("<font size=-2><i>Nothing Scheduled</i><br></font>");
}else{
while ($row = mysql_fetch_array($result)){
$worktime = $row[time];
$time = substr($worktime,0,5);
echo ("<font size=-2>$time - ".$row[comment]."<br></font>");
}
}
echo ("<br>");
}
Thanks in advance...if you want more info give me a shout :)
You can see the output of this at http://www.clanunwanted.f2s.com/new/dates.php
Funkster
ICQ: 62038286
[ 20 March 2001: Message edited by: FunkyBlueStick ]
// Open SQL Connection
$db="udubs";
$table="calendar";
mysql_pconnect("db.clanunwanted.f2s.com","*****","*****")
or die("Could not connect to the database server... Please try later!");
// Loop to display next 7 days
for ($counter=0; $counter<=7; $counter++){
echo ("<font size=-2>".gmdate("D d M Y", mktime(0,0,0, gmdate(m), gmdate(d)+$counter, gmdate(Y)))."</font>");
echo ("<br>");
$date = gmdate("Y-m-d", mktime(0,0,0, gmdate(m), gmdate(d)+$counter, gmdate(Y)));
echo ("<font size=-2>$date</font>");
echo ("<br>");
// Make SQL Query
$sql = "select * from $table where date = $date order by time";
$result = mysql_db_query($db,$sql);
$numrows = mysql_num_rows($result);
if (!$numrows == 0){
echo ("<font size=-2><i>Nothing Scheduled</i><br></font>");
}else{
while ($row = mysql_fetch_array($result)){
$worktime = $row[time];
$time = substr($worktime,0,5);
echo ("<font size=-2>$time - ".$row[comment]."<br></font>");
}
}
echo ("<br>");
}
Thanks in advance...if you want more info give me a shout :)
You can see the output of this at http://www.clanunwanted.f2s.com/new/dates.php
Funkster
ICQ: 62038286
[ 20 March 2001: Message edited by: FunkyBlueStick ]