burnsy
Well-Known Member
i'm trying to get a search form for mysql to work to search top gear episode information. i'm using this template:
in my code, i added a print to the else, and no matter what i put into the text box, it comes back with the else. what am i missing?
Code:
<?php
if ($searchstring)
{
$sql="SELECT * FROM episodes WHERE Car LIKE "\%$search%\"";
$db = mysql_connect("localhost", "root", "therunner");
mysql_select_db("test",$db);
$result = mysql_query($sql,$db);
echo "<TABLE BORDER=2>";
echo"<TR><TD>[B]Full Name[/B]<TD>[B]Nick Name[/B]<TD>[B]Options[/B]</TR>";
while ($myrow = mysql_fetch_array($result))
{
echo "<TR><TD>".$myrow["Episode"]."</td><td>".$myrow["Date"]."</td><TD>".$myrow["Time"]."</td><TD>".$myrow["Type"]."</td><TD>".$myrow["Car"]."</td><TD>".$myrow["Description"]."</td><TD>".$myrow["Presenter"]."</td></tr>";
}
echo "</TABLE>";
}
else
{
echo "Enter Search";
}
{
?>
<form method="POST" action="<?php $PHP_SELF ?>">
<table border="2" cellspacing="2">
<tr><td>Insert you search string here</td>
</tr>
<tr>
<td><input type="text" name="search" size="28"></td>
</tr>
</table>
<input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>
<?php
}
?>