updates to fix searching

This commit is contained in:
Dan Olson 2000-06-16 05:24:11 +00:00
parent 8353c23892
commit e6559de260
4 changed files with 77 additions and 74 deletions

View file

@ -1,64 +1,28 @@
<?
function newsItem( $date, $user, $text )
{
if ($user == "Theoddone33") $user = "theoddone33";
echo '<TR><TD><DL><DT><FONT SIZE=-1>Posted on ' . $date . ' by ' . $user . '</FONT></DT>' .
' <DD><P>' . $text . '</DD>' .
'</DL></TD></TR>';
}
function listMonths ( )
{
$startyear = 2000;
$today = getdate ();
while ($startyear <= $today['year'])
{
for ($month = $today['mon']+1 ; $month > 1 ; $month--)
{
echo '<P><A HREF="old_news.php?mon=' .
date ("m", mktime (0,0,0,$month,0,0,0)) .
'&yr=' .
date ("Y", mktime (0,0,0,0,0,$today['year']+1,0)). '">' .
date ("F, Y", mktime (0,0,0,$month,0,$today['year'],0)) .
'</A>';
}
$today['year']--;
}
}
function searchNews ($string)
{
need ('date sql');
$search = "\'%$string%\'";
$conn = @mysql_pconnect (sqlHost, sqlUser, sqlPass);
if ($conn) {
$query = 'SELECT n_date, n_user, n_news FROM news_main WHERE '.
'n_news LIKE ' . $search . ' 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.';
}
}
?>
<?
function newsItem( $date, $user, $text )
{
if ($user == "Theoddone33") $user = "theoddone33";
echo '<TR><TD><DL><DT><FONT SIZE=-1>Posted on ' . $date . ' by ' . $user . '</FONT></DT>' .
' <DD><P>' . $text . '</DD>' .
'</DL></TD></TR>';
}
function listMonths ( )
{
$startyear = 2000;
$today = getdate ();
while ($startyear <= $today['year'])
{
for ($month = $today['mon']+1 ; $month > 1 ; $month--)
{
echo '<P><A HREF="old_news.php?mon=' .
date ("m", mktime (0,0,0,$month,0,0,0)) .
'&yr=' .
date ("Y", mktime (0,0,0,0,0,$today['year']+1,0)). '">' .
date ("F, Y", mktime (0,0,0,$month,0,$today['year'],0)) .
'</A>';
}
$today['year']--;
}
}
?>

32
news_search.php Normal file
View file

@ -0,0 +1,32 @@
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.';
}

View file

@ -72,9 +72,9 @@
echo '<CENTER><FONT size="-2">' .
'<FORM action="search.php" method="POST">' .
' <SELECT name="type_of_search">' .
' <OPTION value="news">News</OPTION>' .
' <OPTION value="bugs">Bug Tracking</OPTION>' .
' <OPTION value="lists">Mailing Lists</OPTION>' .
' <OPTION value="news">News</OPTION>' .
' <OPTION value="patches">Patches</OPTION>' .
' </SELECT>' .
' <BR>' .

View file

@ -1,9 +1,16 @@
<? // Preamble
$pageName = "Search";
$focused = "none"; // Dock icon name to gets a border
require("parts/preamble.php"); // Load most of document
?>
This page is still under construction. Please check back later.
<?
require("parts/postamble.php"); // Finish this sucker up
?>
<? // Preamble
$pageName = "Search";
$focused = "none"; // Dock icon name to gets a border
require("parts/preamble.php"); // Load most of document
?>
<?php
if ($type_of_search == "news") {
$string = $search;
include("news_search.php");
}
else
echo '<P>That type of search isn't supported yet. Please check back later.';
?>
<?
require("parts/postamble.php"); // Finish this sucker up
?>