S
strawberry
Guest
I want to create a simple search engine that pulls document details out of my sql database using php.
My form uses POST to carry the term 'search' to the next page, but when i try to use it to query the results in teh database i can only get it to pull all records or nothing. What am i doing wrong !!!!
<?php
mysql_connect("localhost", "xxxxx", "xxxxx") or die(mysql_error());
mysql_select_db("xxxxx") or die(mysql_error());
$search=$_POST['search'];
echo "$search";
//get the mysql and store them in $result
//change whatevertable to the mysql table you're using
//change whatevercolumn to the column in the table you want to search
$search = mysql_query("SELECT * FROM documents WHERE 'descr' LIKE '%$search%'")
or die(mysql_error());
//grab all the content
while($row = mysql_fetch_array($search))
{
$anch=$row ["anch"];
$descr=$row ["descr"];
$id=$row ["id"];
$pdate=$row ["pdate"];
//display the row
echo "$anch <br> $descr <br> $pdate <br>";
}
?>
My form uses POST to carry the term 'search' to the next page, but when i try to use it to query the results in teh database i can only get it to pull all records or nothing. What am i doing wrong !!!!
<?php
mysql_connect("localhost", "xxxxx", "xxxxx") or die(mysql_error());
mysql_select_db("xxxxx") or die(mysql_error());
$search=$_POST['search'];
echo "$search";
//get the mysql and store them in $result
//change whatevertable to the mysql table you're using
//change whatevercolumn to the column in the table you want to search
$search = mysql_query("SELECT * FROM documents WHERE 'descr' LIKE '%$search%'")
or die(mysql_error());
//grab all the content
while($row = mysql_fetch_array($search))
{
$anch=$row ["anch"];
$descr=$row ["descr"];
$id=$row ["id"];
$pdate=$row ["pdate"];
//display the row
echo "$anch <br> $descr <br> $pdate <br>";
}
?>