CP Home
Database
Description
Script Index
I-5 QMC
MySQL
Database
SQL
PHP
HTML
Email

schedule - Public WWW Script

Produces a page of scheduled events for the club website



Script: schedule.php

Input

From racing database:
  1. html.Head | text
  2. html.Menu_Top | text
  3. html.Menu_Bottom | text
  4. html.Tail | text
  5. events.Event_Num | integer
  6. events.Event_Date | date
  7. events.Thru_Date | date
  8. events.Description | text
  9. events.URL | text
  10. events.Location | text
  11. CURDATE() | today's date
  12. DATE_SUB(CURRENT_DATE, INTERVAL 1 DAY) | yesterday's date
Actions



Output

To Display:






<?php
$link = mysql_connect('IG88', 'USER_ID', 'PASSWORD');
if (!$link) {
  die('Could not connect: ' . mysql_error());
}
mysql_select_db(racing);


$query = "select * from html where Home_Club = 'I-5'";

$result = mysql_query($query) 
  or die("Cannot execute query");
$row = mysql_fetch_assoc($result);
echo $row['Head'];
echo $row['Menu_Top'];
$html_tail = $row['Tail'];


$today20 = "SELECT CURDATE()";
$result20 = mysql_query($today20) 
  or die("Cannot execute current date");
$row20 = mysql_fetch_array($result20);
$todays_date = $row20[0];

$yesterday = "SELECT DATE_SUB(CURRENT_DATE, INTERVAL 1 DAY)";
$result21 = mysql_query($yesterday) 
  or die("Cannot execute yester date");
$row21 = mysql_fetch_array($result21);
$yester_date = $row21[0];

$query23 = "select Event_Num from events where ((Event_Date = '$todays_date') OR (Event_Date = 
'$yester_date')) AND ((Event_Scope = 'Outlaw') or (Event_Scope = 'Fun') or (Event_Scope = 
'Club Points')) AND Location = 'Home Track' and Home_Club = 'I-5'";

$result23 = mysql_query($query23) 
  or die("Cannot execute query");
if($row23 = mysql_fetch_assoc($result23)){
  echo '<tr><td width="120" height="23"  bgcolor="#FE0002" align="center" valign="center">';
  echo '<a href="http://www.i-5qmc.com/race_day.php"><font size="2" face="Helvetica">Race Day';
  echo '</font></a></td></tr>';
}

?>

<!--
The menu is divided in 2 parts so additional menu items can be added. This would accomodate lower
tier page menu item that you do not want on the main menu. Place the html for menu rows here.
-->

<?php
echo $row['Menu_Bottom'];

echo '<p valign="top" align="center"><b><i><font size="6" color="#fff47c">Schedule<br>';
echo '<font size="2" color="#fff47c">Click on Description to see results of races past';
echo '</font></i></b></a><br></p>';

$query = "select * from events where Home_Club = 'I-5' order by Event_Date";

$result = mysql_query($query) 
  or die("Cannot execute query");

echo '<table border=2 cellpadding="10"><tr><td align="center" bgcolor="#0B2F85">
<font color="white">Date</font></td><td align="center" bgcolor="#0B2F85">';
echo '<font color="white">Description</font></td><td align="center" bgcolor="#0B2F85">
<font color="white">Location</font></td><td align="center" bgcolor="#0B2F85">
<font color="white">Race Type</font></td></tr>';

while($row = mysql_fetch_assoc($result)){

echo '<tr>';

$ev_n = $row['Event_Date'];
$event_dayname = "SELECT dayname('$ev_n')";
$result1 = mysql_query($event_dayname) 
  or die("Cannot execute event day name");
$row1 = mysql_fetch_array($result1);

$ev_m = $row['Event_Date'];
$event_month = "SELECT monthname('$ev_m')";
$result2 = mysql_query($event_month) 
  or die("Cannot execute event month");
$row2 = mysql_fetch_array($result2);

$ev_d = $row['Event_Date'];
$event_day = "SELECT DAYOFMONTH('$ev_d')";
$result3 = mysql_query($event_day) 
  or die("Cannot execute event day");
$row3 = mysql_fetch_array($result3);

if ($row['Thru_Date'] != "0000-00-00"){

$ev_nn = $row['Thru_Date'];
$event_dayname2 = "SELECT dayname('$ev_nn')";
$result4 = mysql_query($event_dayname2) 
  or die("Cannot execute event day name2");
$row4 = mysql_fetch_array($result4);

$ev_mm = $row['Thru_Date'];
$event_month2 = "SELECT monthname('$ev_mm')";
$result5 = mysql_query($event_month2) 
  or die("Cannot execute event month2");
$row5 = mysql_fetch_array($result5);

$ev_dd = $row['Thru_Date'];
$event_day2 = "SELECT DAYOFMONTH('$ev_dd')";
$result6 = mysql_query($event_day2) 
  or die("Cannot execute event day2");
$row6 = mysql_fetch_array($result6);


	if ($row['URL'] == NULL) {
	echo '<td>'.$row1[0].', '.$row2[0].' '.$row3[0].'<br>through ';
	echo $row4[0].', '.$row5[0].' '.$row6[0].'</td><td>';
	echo $row['Description'].'</td><td>';

		if ($row['Location']){
		echo $row['Location'];
		}
	} else {

	echo '<td>'.$row1[0].', '.$row2[0].' '.$row3[0].'<br>through ';
	echo $row4[0].', '.$row5[0].' '.$row6[0].'</td><td>';
	echo '<a href="'.$row['URL'].'"><u></font><font size="4"';
 	echo ' face="Helvetica" color="#fff47c">'.$row['Description'];
	echo '</u></a></font></td><td>';

		if ($row['Location']){
		echo $row['Location'];
		}
	}

} else {

	if ($row['URL'] == NULL) {
	echo '<td>'.$row1[0].', '.$row2[0].' '.$row3[0].'</td><td>';
	echo $row['Description'].'</td><td>';

		if ($row['Location']){
		echo $row['Location'];
		}

	} else {

	echo '<td>'.$row1[0].', '.$row2[0].' '.$row3[0];
	echo '</td><td><a href="'.$row['URL'].'"><u>';
 	echo '<font color="#fff47c" face="Helvetica">'.$row['Description'];
	echo '</u></a></font></td><td>';

		if ($row['Location']){
		echo $row['Location'];
		}
	}
}
echo '</td><td>'.$row['Event_Scope'].'</td></tr>';

}
echo '</table></font>';
echo $html_tail;

?>