website/news_search.php
2000-06-16 05:38:06 +00:00

33 lines
No EOL
1.7 KiB
PHP

<?php
need ('date sql');
require("news_funcs.php");
$searchString = "'%$string%'";
$conn = @mysql_pconnect (sqlHost, sqlUser, sqlPass);
if ($conn) {
$query = 'SELECT n_date, n_user, n_news FROM news_main WHERE '.
'n_news LIKE ' . $searchString . ' ORDER BY n_date DESC';
$result = @mysql_db_query (sqlDB, $query, $conn);
if ($result) {
$numRows = @mysql_num_rows ($result);
if ($numRows) {
echo '<TABLE width="100%" cellSpacing="0" cellPadding="0" border="0">'.
' <TR vAlign="top"> <TD colSpan="2">';
tableBoxHeader( 'black', tableHeadColor );
tableTitle( "Search Results", 1, tableHeadColor );
for ($i = 0 ; $i < $numRows ; $i++) {
list ($n_date, $n_user, $n_news) = mysql_fetch_row ($result);
newsItem (dateFromSQLDateTime ($n_date), $n_user, StripSlashes($n_news));
}
tableBoxFooter();
echo '</TD></TR></TABLE>';
} else {
echo '<P>No news found matching "' . $string . '"';
}
} else {
echo '<P>No news found matching "' . $string . '"\n';
}
mysql_close ($conn);
} else {
echo '<P>SQL error, please contact the webmaster.';
}
?>