mercredi 30 avril 2014

how can I stay in the same page when user insert null value in search box


Vote count:

0




I have a Header, which I include it in every page, that contain search when the user enter value it will display the result but when he/she but null value in the text box it display all the result in the database how can I prevent that and stay in the same page where he/she is


--- HTML---



<form action="search.php" method="post">
<input type="search" placeholder=" search..."name="data" style=" margin:30px 0px 0px 0px; ">
<input type="submit" style="visibility:hidden" name="search"/>
</form>


--- php ---



$search=$_POST['data'];

$data2 = mysql_query("select * from project,person where project.projectname LIKE '%$search%' and person.personstatus=1 and project.status='submitted' and project.personid=person.personid") or die(mysql_error());

if (mysql_num_rows($data2)){
echo '<div style="width:1170px;min-height:100%; margin:20px 90px 0px 0px;
display:inline-block; background-color:#fff;">
<h2 style="color:rgb(58,147,231);font-size:20px;"> Project </h2> ';
while($info = mysql_fetch_array( $data2 ))
{
$projectid=$info['projectid'];
$img=$info['imgProject'];
$proName=$info['projectname'];
$type=$info['projecttype'];
$person=$info['personid'];
$personname=$info['personname'];

echo '<a href="project.php?projectid='.$projectid.'"><div class="note" style=" background-color:#E6E6E6; display:inline-block;width:200px; height:250px; margin-left:30px;">';
echo '<center><h4 style="color:rgb(58,147,231);">'.$proName.'</h4>';
echo'<img src="'.$img.'" width="200" height="160"><br>';
echo'<b>Project name : </b>'.$personname.'<br>';
echo'<b>Project type : </b>'.$type.'<br>';

echo' </div></a></center>';
}
}
else {
$errors[]="NO result found";
}
echo '</div>';


I hope you can help me solve this problem



asked 1 min ago






Aucun commentaire:

Enregistrer un commentaire