I'm having a little problem extracting the results from my database that match a variable from a form.
Page one has the form:
<form name="searchtitle" method="post" action="results.html">
Find
<input type="text" name="textsearch">
in the Title
<input type="submit" name="submit" value="Go!">
</form>
Page two should extract "textsearch" from the db.
<?
$connection = mysql_connect("server", "username", "passwod")
or die ("Couldn't connect to server.");
$db = mysql_select_db("databasename", $connection)
or die ("Couldn't select database.");
$sql = "SELECT * FROM table WHERE title = '*$textsearch' ORDER by title ASC ";
$sql_result = mysql_query($sql,$connection)
or die ("Couldn't get list!");
?><?
echo "
<table width=\"75%\" border=\"1\" cellpadding=\"1\">
<tr>
<td><b><font size=\"+1\">Title</font></b></td>
<td>
<div align=\"center\"><b><font size=\"+1\"> Price </font></b></div>
</td>
<td>
<div align=\"center\"><b><font size=\"+1\"> Disc </font></b></div>
</td>
</tr>";
while ($row = mysql_fetch_array($sql_result)) {
$id = $row["id"];
$title = $row["title"];
$price = $row["price"];
$disc = $row["disc"];
echo "
<tr>
<td>$title</td>
<td><div align=\"center\"> $price </font></div></td>
<td><div align=\"center\"> $disc </font></div></td>
</tr>
";
}
?>
Currently, this just shows the headers.
I've run a querry that selects all to test the rest of the code, so my problem is just with the $sql = line.
I'd like the user to be able to enter "pple" and have the results show
apple
apples
green apples
applesause
Any and all help would be much appriciated.
BTW - I have RTM- I'm more lost than ever.