Přidat otázku mezi oblíbenéZasílat nové odpovědi e-mailem Jak naprogramovat search na web

I assume you have one textbox in your website :

<form id="frmSearch" name="frmSearch" method="GET" action="searchResult.php">
<input type="text" id="fldSearch" name="fldSearch" value="Search"/>
<input type="button" id="btnGo" name="btnGo" value="Go"/>
</form>
Now Let assume user enter some text in the form and press the Go button.
So inside your searchResult.php you will receive the user entered text as follow
$searchStr = trim($_GET['fldSearch']);
$searchStr = ( $searchStr!="" ) ? $searchStr : "";

if( $searchStr!="" ) {

$con=mysqli_connect("example.com","example","1234" ,"my_db");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

//Prepare a MySQL query string
// assuming you have description and name field in the photo album database.

query = "SELECT CONCAT_WS(name,description) as cnd where cnd LIKE '%".$searchStr ."%' ";

//Execute it and fetch the result into the variable
$result = mysqli_query($con,query );

while($row = mysqli_fetch_array($result))
{
// Show the results in your way
}
mysqli_close($con);

}

Reakce na odpověď

1 Zadajte svou přezdívku:
2 Napište svou odpověď:
3 Pokud chcete dostat ban, zadejte libovolný text:

Zpět do poradny