Code: Select all
<?
$searchin2 = "";
$searchmember2 = "";
$searchmember3 = "";
$searchforum2 = "";
$searchforum3 = "";
IF($_GET[submit] == "Search"){
IF($_GET[query] != "" OR $_GET[member] != ""){
echo "
<html>
<head>
<title>Search Results</title>
</head>
<body>
<p><font size='5'><b>Search Results</b></font></p>
<table border='0' width='100%' cellspacing='0' cellpadding='0'>
<tr>
<td align='left' width='55%'><b>Topic</b></td>
<td align='left' width='20%'><b>Date</b></td>
<td align='left' width='25%'><b>Forum</b></td>
</tr>";
include('connect.php');
$user_id_query = mysql_query("SELECT user_id FROM users WHERE username='$_GET[member]' LIMIT 1");
while($row = mysql_fetch_array($user_id_query))
{
$user_id = $row['user_id'];
}
IF($_GET[member] == ""){
$searchmember2 = "";
}ELSEIF($_GET[member] != ""){
$searchmember2 = "AND post_userid='$user_id'";
$searchmember3 = "AND reply_user_id='$user_id'";
}
IF($_GET[searchforum] == ""){
$searchforum2 = "";
$searchforum3 = "";
}ELSEIF($_GET[searchforum] != ""){
$searchforum2 = "AND post_forum='$_GET[searchforum]'";
$searchforum3 = "AND reply_forum='$_GET[searchforum]'";
}
IF($_GET[searchin] == "message"){
$searchin2 = "post_text";
}ELSEIF($_GET[searchin] == "subject"){
$searchin2 = "post_subject";
}
$search_reply = mysql_query("SELECT * FROM reply WHERE reply_text LIKE '%$_GET[query]%' OR reply_user_id='%$_GET[member]%' $searchmember3 $searchforum3 ORDER BY reply_date DESC");
while($row2 = mysql_fetch_array($search_reply)){
$reply_post_id = $row2["reply_post_id"];
$reply_id = $row2["reply_id"];
IF($reply_post_id == ""){
$searchreply = "";
$reply_link = "";
}ELSEIF($reply_post_id != ""){
$searchreply = "AND post_id='$reply_post_id'";
$reply_link = "#$reply_id";
}
$row2_count++;
}
$search_thread = mysql_query("SELECT * FROM post WHERE $searchin2 LIKE '%$_GET[query]%' OR post_userid LIKE '%$_GET[member]%' $searchmember2 $searchforum2 $searchreply ORDER BY post_date DESC");
while($row = mysql_fetch_array($search_thread)){
$forum_id=$row["post_forum"];
$post_subject=$row["post_subject"];
$post_id = $row["post_id"];
$post_date = $row["post_date"];
$date = date("F j, Y",$post_date);
$forum_name_query = mysql_query("SELECT forum_name FROM forum WHERE forum_id='$forum_id'");
while($row = mysql_fetch_array($forum_name_query))
{
$forum_name = $row['forum_name'];
}
echo "
<tr>
<td align='left' width='55%'><a href='viewtopic.php?t=$post_id$reply_link'>$post_subject</a></td>
<td align='left' width='20%'>$date</td>
<td align='left' width='25%'><a href='viewforum.php?f=$forum_id'>$forum_name</a></td>
</tr>
";
$row_count++;
}}
?>
</table>
</body>
</html>
<?
}ELSEIF($_GET[query] == "" AND $_GET[member] == ""){
?>
<html>
<head>
<meta http-equiv='Content-Language' content='en-us'>
<title>Search the Forums</title>
</head>
<body>
<form method='GET' action='search.php'>
<table border='0' width='100%' cellspacing='1'>
<tr>
<td align='right' width='50%'>Search Words:</td>
<td align='left' width='50%'>
<input type='text' name='query' size='34'></td>
</tr>
<tr>
<td align='right' width='50%'>Search Forum:</td>
<td align='left' width='50%'><select size='1' name='searchforum'>
<option value=''>Choose a Forum</option>
<option value=''>--------------</option>
<option value=''>All Forums</option>
<option value=''>--------------</option>
<?
include('connect.php');
$query = mysql_query("SELECT * FROM forum ORDER BY forum_name ASC");
while($row = mysql_fetch_array($query)){
$forum_name=$row["forum_name"];
$forum_id=$row["forum_id"];
echo "
<option value='$forum_id'>$forum_name</option>
";
$i++;
}
?>
</select></td>
</tr>
<tr>
<td align='right' width='50%'>Search In:</td>
<td align='left' width='50%'><select size='1' name='searchin'>
<option selected value='message'>Entire Message</option>
<option value='subject'>Subject</option>
</select></td>
</tr>
<tr>
<td align='right' width='50%'>Member Name:</td>
<td align='left' width='50%'>
<input type='text' name='member' size='26'></td>
</tr>
</table>
<p> </p>
<p align='center'><input type='submit' value='Search' name='submit'></p>
</form>
</body>
</html>
<?
}
?>feyd | hey look ma,
Code: Select all
works now. [/color]