I tried to use the data from this form which is located in my main page - index.php.
<center>
<form action="search.php" method="post">
<input type="text" name="search" size="30" />
<select name='wheretosearch'>
<option value='Articles'>Articles</option>
<option value='Users'>Members</option>
</select>
<input type="submit" value="Search" />
</form>
</center>
This is the main part of search.php code:
include "all/config.php";
$search = $_REQUEST['search']; //Getting the words
$split = split(" ",$search); //If there is more than one I spit them.
foreach ($split as $array => $value)
{ $NewResult .= $value;
}
$wheretosearch = $_POST['wheretosearch'];
if ($wheretosearch = 'Articles')
{$Results = mysql_query("SELECT * FROM bgarticles WHERE title LIKE '%$value%' OR description LIKE '%$value%' OR text LIKE '%$value%' OR tags LIKE '%$value%' OR date LIKE '%$value%' OR author LIKE '%$value%' OR ip LIKE '%$value%' ");
while($row = mysql_fetch_array($Results))
{
echo "<div class='top'>";
echo "<span class='title'>";
echo "<a href=details.php?id=$row[id]>";
echo $row['title'];
echo "</a>";
echo "</span> <br><br>";
echo "<span class='author'>";
echo $row['author'];
echo "</span>";
echo "<span class='date'> Date: ";
echo $row['date'];
echo "</span> <br><br><br>";
echo "<br><br></div>" ;
echo "<div class='bottom'><br><br></div>";
}
}
if ($wheretosearch = 'members')
{$Results2 = mysql_query("SELECT * FROM members WHERE username LIKE '%$value%' OR firstname LIKE '%$value%' OR lastname LIKE '%$value%' ");
while($row2 = mysql_fetch_array($Results2))
{
echo "<div class='top'>";
echo "<span class='title'>";
echo "<a href=details.php?id=$row2[id]>";
echo $row2['username'];
echo "</a>";
echo "</span> <br><br>";
echo "<span class='author'>";
echo $row2['firstname'];
echo "</span>";
echo "<span class='date'> Date: ";
echo $row2['date'];
echo "</span> <br><br><br>";
echo "<br><br></div>" ;
echo "<div class='bottom'><br><br></div>";
}
}
No matter I do it always shows data from both mysql tables. Why?