[TV Guide | Show Search]

">

document.f.q.focus(); /* just like Google */

Search for a show by name.

"); #mysql_select_db('tv'); // Builds channel name/number table $sql = "SELECT id, affiliate, callSign, channel FROM stations ORDER BY channel"; $query = mysql_query($sql) or die(mysql_error()); $num_rows = mysql_num_rows($query); for($i = 0; $i < $num_rows; $i++) { $channel = mysql_fetch_object($query); $channels[$channel->id] = array('callSign' => $channel->callSign, 'channel' => $channel->channel); if ($channel->channel <= "10" ) $channels[$channel->id][callSign] = trim(str_replace('Affiliate','', $channel->affiliate)); } // Runs the search if ($sid == '') { $sql_where = 'title LIKE \'%'.addslashes($search).'%\' OR MATCH (title'; if ($_GET['type'] == 'search') $sql_where .= ', description'; # Doesn't work on older versions of MySQL # $sql_where .= ') AGAINST (\''.addslashes($search).'\' IN BOOLEAN MODE)'; $sql_where .= ') AGAINST (\''.addslashes($search).'\')'; } else { $sql_where = 'title = \''.addslashes($sid).'\''; } $now = undo_dst(time()); $sql = "SELECT stime, etime, title, subtitle, description, station, uniq ". "FROM programs WHERE (etime > '$now' AND ($sql_where)) ORDER BY stime ASC"; // "title LIKE '$search_sql') ". // "title SOUNDS LIKE '$ssearch') ". # "MATCH (title) AGAINST ('$ssearch' IN BOOLEAN MODE)) ". # "ORDER BY stime ASC"; # echo "\n"; $query = mysql_query($sql) or die(mysql_error()); // index channel name/numbers by station_id here // some globals for the day_set $last_date = ''; $n = mysql_num_rows($query); #echo "

Found $n shows.

(No longer accurate.)

"; if ($n == 0) die(""); // catches $_GET['strict'] == '' AND !isset($_GET['strict'] if ($_GET['type'] == 'exact') { $metaphs = metaphone($search); $mlen = strlen($metaphs)/2; // allows more fudging for longer names /* A hack. Oh well. */ if (in_array(strtoupper($search), $strict_exceptions)) { $mlen /= 2; } } for ($i = mysql_num_rows($query) + 1; $i > 1; --$i) { $p = mysql_fetch_object($query); if ($_GET['type'] == 'exact') { $strcmp = levenshtein(metaphone($p->title), $metaphs); if (($index = strpos($p->title, ":")) !== FALSE) { $substrcmp = levenshtein(metaphone(substr($p->title, 0, $index)), $metaphs); $strcmp = min($strcmp, $substrcmp); } if ($strcmp > $mlen) continue; } $channel = $channels[$p->station]; set_date(date('l, F jS', do_dst($p->stime))); if ($p->description) { echo ""; } echo "
\n"; if ($p->description) { echo "\t\n"; } echo "\t
".$p->title.""; if ($p->subtitle) { echo ": {$p->subtitle}"; } echo "
\n"; echo "\t
".date('g:i A', do_dst($p->stime)).' - '. date('g:i A', do_dst($p->etime)).' on '. $channel['callSign'].' ('.$channel['channel'].')
'; # echo '
diff(title, search): '.$strcmp.'
'; echo ""; if ($p->description) echo '
'; echo "\n"; ob_flush(); flush(); } ?> \n"; echo "
$day
\n"; $last_date = $day; } else echo "
\n"; } ?>