NameSilo

Search Page

Spaceship Spaceship
Watch
OK This tutorial will show you how to make a search page.

Firstly we make a form. I am going to use this:

PHP:
<form method="post" action="searchpage.php">
<p>Please enter keyword.</p>
<p>
<input name="word" type="text" size=25 maxlength=25>
</p>
<p>
<input type="Submit" name="Submit" value="Submit">
</p>
</form>
This is the form where we will enter the keywords. Now the next step is to make the searchpage.php.

It will look like this

PHP:
<?php
// connect to db
$db = mysql_connect("localhostt", "username", "password");
mysql_select_db("dbname",$db);

//check something is sent
if ($_POST['word']) {
$word= $_POST["word"];
// search query
$result = mysql_query("SELECT * FROM `table` WHERE `field` LIKE '%$word%'");
$postword = $_POST['word'];
echo "Search Results for: <strong> $postword </strong> <br />";
echo"<p> </p>";
echo"<p> </p>";
echo"<p> </p>";
echo"<p> </p>";
//get results
while($get=mysql_fetch_array($result))
{


$date = $get['date'];
$name = $get['name'];
$title= $get['title'];

//show results
echo("<strong>$title</strong> was added on <strong>$date</strong> by <strong>$name</strong>");

echo"<p></p>";
echo"<p></p>";
}
// if nothing is sent
}else {
die ("No search word specified");
}

?>
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Dynadot — .com Registration $8.99Dynadot — .com Registration $8.99

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Live Options
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back