Creating a search engine

At the moment I am working on making a search engine for our website which will help the users be able to filter through the posts if they are looking for a specific topic or area of the website. I have managed to get a really basic one working but need to link it correctly to our database so we can search specific posts, however that should be easy to change.

search Above: How the search bar currently appears.


Above: Showing that when no information is added, a message of ‘could not search!’ is given out


if(isset($_POST["search"])) {
$searchq= $_POST["search"];

$query = mysql_query("SELECT * FROM posts WHERE firstname LIKE '%$searchq%' OR lastname LIKE '%searchq%'") or die("could not search!");

$count= mysql_num_rows($query);
$output = 'There was no search results!';
while ($row=mysql_fetch_array($query)) {
$fname = $row['firstname'];
$lname =$row['lname'];

$output .='<div>'.$fname.''.$lname.'</div>';

<!DOCTYPE html>






<form action="index3.php" method="post">

<input type="text" name="search" placeholder="Search for members..."/>
<input type="submit" value=">>" />

<?php print("$output");?>


Below is a very useful video which I used to help me create this.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s