website/news_search.php

33 lines
1.7 KiB
PHP
Raw Normal View History

2000-06-16 05:24:11 +00:00
need ('date sql');
$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);
echo $query;
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 . '"\n';
}
} else {
echo '<P>No news found matching "' . $string . '"\n';
}
mysql_close ($conn);
} else {
echo '<P>SQL error, please contact the webmaster.';
}