$browse = $_GET['browse']; if (!isset($browse)) { $browse = ''; } $server="localhost"; $user="CAS"; $pw="lotuselanK1!"; $cn = mysql_connect ($server,$user,$pw) or die('bollocks'); mysql_select_db("csdb"); if ($browse == '') { scr_home(); } else { scr_browse($browse); } function scr_browse($browse) { $beforeorafter['a'] = "after"; $beforeorafter['A'] = "after"; $beforeorafter['b'] = "before"; $beforeorafter['B'] = "before"; $tide['h'] = "high Water"; $tide['H'] = "high Water"; $tide['l'] = "low Water"; $tide['L'] = "low Water"; echo "\n"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "";
$sqlq = "select * from slacks order by slk_site";
$rs = mysql_query($sqlq);
$NumRows = mysql_num_rows($rs);
$last_init = '*';
for ($i=1;$i<=$NumRows;$i++) {
$k=mysql_fetch_row($rs);
if (strtoupper(substr($k[0],0,1)) != $last_init) {
echo "";
echo "[".strtoupper(substr($k[0],0,1))."]";
echo "";
}
$last_init = strtoupper(substr($k[0],0,1));
}
echo "\n\n";
$sqlq = "select * from slacks where slk_site like '".$browse."%' order by slk_site, slk_tide_place, slk_h_or_l, slk_b_or_a desc, slk_mins";
$rs = mysql_query($sqlq);
$NumRows = mysql_num_rows($rs);
echo "Sites begining with \"".$browse."\"...\n\n\n";
$lastsite = '';
for ($i=1;$i<=$NumRows;$i++) {
$k = mysql_fetch_row($rs);
if (strtoupper($k[0]) != $lastsite) {
echo $k[0]."\n";
}
$hours = floor($k[1] / 60);
$mins = $k[1] - (floor($k[1] / 60) * 60);
echo " - ".$hours." hours ".$mins." minutes ".$beforeorafter[$k[2]]." ".$tide[$k[3]]." at ".$k[4]."\n";
$lastsite = strtoupper($k[0]);
}
echo "\n";
echo "\n";
echo "";
}
function scr_home() {
$sqlq = "select * from slacks order by slk_site";
$rs = mysql_query($sqlq);
$NumRows = mysql_num_rows($rs);
$last_init = '*';
echo "\n";
echo "\n";
echo "\n";
echo "\n";
echo "\n";
echo "\n";
echo "\n";
echo "This is the Slack Water Database. Find out when slack water is at your favourite divesites.\n";
echo "If you forget to check before you go or have a change of site at the last minute you can also\n";
echo "find the Slack Water Database on your WAP enabled mobile phone by pointing it towards\n";
echo "http://wap.calumscott.me.uk.\n\n\n";
echo "Where slack can occur between certain times, the earlier is given to ensure you are at the site\n";
echo "in plenty of time!\n\n\n";
echo "Just click on the first letter of the site you are interested in...\n\n\n";
for ($i=1;$i<=$NumRows;$i++) {
$k=mysql_fetch_row($rs);
if (strtoupper(substr($k[0],0,1)) != $last_init) {
echo "";
echo "[".strtoupper(substr($k[0],0,1))."]";
echo "";
}
$last_init = strtoupper(substr($k[0],0,1));
}
echo "\n\n";
$sqlq = "select count(distinct(slk_site)) from slacks";
$rs = mysql_query($sqlq);
$Row = mysql_fetch_row($rs);
$NumSites = $Row[0];
echo "The slackbase currently holds details for ".$NumSites." sites. If you have any slack water\n";
echo "information you would like to share please email me with the details on the email address on\n";
echo "the contact page.\n";
echo "\n";
echo "\n";
echo "";
}
?>