Search Engine

Here is the code that should link to the database and allow the users to search for specific posts.


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)) {
$tweet = $row['tweet'];
$userid =$row['userid'];

$output .='<div>'.$tweet.''.$userid.'</div>';

<!DOCTYPE html>






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

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

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



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