i wanna create filters by using textbox and dropdown list

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
u5113499
Forum Newbie
Posts: 1
Joined: Mon Jan 30, 2017 5:47 am

i wanna create filters by using textbox and dropdown list

Post by u5113499 »

i dont know why my below code filter only by textbox
when i select dropdown list, system just give me whole data (did not filter any thing)

Code: Select all

$mon = $_POST['val'];
}
$link = mysql_connect("localhost","root","1234");
mysql_query("Use igstore");
if($_GET['submit'] !== null){
$sql = "SELECT * FROM `creator` WHERE `title` LIKE '%$find%'";}//textbox
if($_POST['val'] !== null){
$sql = "SELECT * FROM `creator` WHERE `aprice` LIKE '$mon'";}//dropdown
$result = mysql_query($sql) or die(mysql_error());
while($_GET = mysql_fetch_array($result)){
	  $head = $_GET['title'];
	  $def = $_GET['description'];
	  $pric = $_GET['aprice'];
	  $blob = $_GET['img1'];
	 echo"<html>";
	echo'<table height="180" width="2500">';
	 echo"<tr>";
	 	 echo'<td align="left">';
	echo'<div class="ab">';
	 echo'<img src="data:image/jpeg;base64,'.base64_encode($blob).'"/ width="150px" height="150px">';
	echo'</div>';
	     echo'</td>';
	 	 echo'<td align="right" width="1500">';
		 echo'<div class="container">';
		 echo "<a href='#'><h3>$head</h3></a>";
   	     echo"<label class='control-label col-sm-2'><h5>$def</h5></label><br>";
	     echo"<label class='control-label col-sm-2'><h5>ราคา: $pric</h5></label><br><br>";
		 echo"</div>";
	 	 echo'</td>'; 
	  echo"</tr>";
	 echo'</table>';
	 echo'<hr width="100%">';
	  echo"</html>";
}
?>
Post Reply