i was thinkg some thingklike this. i have a database
image->image_id, image, image_keyword, image_name ...etc
index.php- search bar
<form class='form6' method='post' action='search.php'>
<input type='text' name='search' class='field2'/> //search bar field
<input type='submit' name='search' class='button' value='Search' /> //submit button
</form>
search.php
<?php
include("include/header.php");
$i = 0;
$search_p = $_POST["search"];
$terms = explode(" ", $search_p); //every space new key word
$query = "SELECT * FROM search WHERE"; //get data from sumbit button - NOT SURE IF THIS IS RIGHT
foreach($terms as $each)
{
$i++;
if($i == 1)
$query .= "image_keyword LIKE '%each%'";
else
$query .= "OR keyword LIKE '%each%'";
}
//connet to database
$query_s = mysql_query("SELECT * FROM image");
$row = mysql_num_rows($query_s);
if($row > 0)
{
while($row = mysqlfetch_assoc($query_s))
{
$image_keyword_db = $rows['image_keyword'];
$image_full_name_db = $rows['user_full_name'];
$image_short_name_db = $rows['image_short_name'];
$image_des_db = $rows['image_des'];
echo "$image_short_name_db";
}
}
else
{
echo "no result found";
}
?>
problem is that it print every thing from database. i want to print if $search_p is equal to image_keywor, image_short_name, image_full_name...etc