Making my first steps into php, I've managed to get data out of a database 😃 . Then I started copying examples I'd seen for simple searches, so far I've got (which doesn't work):
<form method="POST" action="">
Search Word: <input type="text" name="search">
<input type="SUBMIT" value="Search!">
</form>
<?php
$connection = mysql_connect("localhost","username","password");
mysql_select_db("database",$connection);
$result = mysql_query("SELECT column1,column2 FROM table WHERE column1 LIKE '%$search%' OR column2 LIKE '%$search%'",$connection);
if($search){
while ($row = mysql_fetch_row($result))
{
for ($i=0; $i<mysql_num_fields($result); $i++)
echo $row[$i] . " ";
echo "<br />";
}
mysql_close($connection);
}
?>
I also tried this example (but I couldn't get it to work 😕 ):
http://www.phpfreaks.com/quickcode/Basic_MySQL_Search/12.php