/*
File Name: Tide Sticker.php
Copyright 2004
Author: Mark Summerlin angler@fish-tails.net
Terms of use: You may modify it freely to suit your needs, however, you may NOT distribute
without express permision from the author.
The author assumes NO liability, and offers NO warranty for its suitability for your use.
Tide Sticker is part of the ongoing Tide Calendar project.
This code snippet retrieves tides from your NOAA tides database for the current date, and displays it.
If you use this code and like it, please let me know.
Instructions:
Change the two variables, then include into a web page where you want the tides to display.
If you are using IIP for UBBThreads you can include it into one of the Custom Boxes
You may need to change some of the html to match your desire output
*/
// Change Only the following variable to the tide id you want in your db in your database
$tide_id = 1;
// Finished with configuration.
/////////////////////////////////////////////////////////////////////////////////////////
////////////////////////DO NOT EDIT BELOW THIS LINE!/////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
$tides_poweredby = 'Fish-Tails.Net';
$tide_sticker_version = '.003';
$query = "
SELECT tide_station,tide_data
FROM {$config['tbprefix']}tides
WHERE tide_id='$tide_id'
";
$plot_tides = $dbh -> do_query($query);
$row = mysql_fetch_assoc($plot_tides);
// Get the current date
$mon = date("n");
$d = date("j");
$year = date("Y");
$date_string = "" . $mon . "/" . $d . "/" . $year;
$lines = $row[tide_data];
$station = $row[tide_station];
// end pulling tidal data
// begin html
echo "Todays Tides at
$station
";
// extract our data and format for output
preg_match_all("|$date_string(\s*\d{1,2}:\d{2,2}[AP]M\s*-?\d+.\d+\s*[HL]){1,4}|",$lines,$matches);
$num = count($matches[0]);
for ($i=0;$i<1;$i++) {
preg_match("|\d{1,2}/\d{1,2}/\d{4,4}|",$matches[0][$i],$date);
preg_match_all("|\d{1,2}:\d{2,2}[AP]M\s*-?\d+.\d+\s*[HL]|",$matches[0][$i],$tideinfo);
echo "".($date[0]."
");
for ($j=0;$j<=count($tideinfo[0]);$j++) {
echo ($tideinfo[0][$j]."
");
}
}
// finish our html
echo "Get More Tides
";
echo "Tide Sticker Powered By $tides_poweredby";
// End Tides
?>