View:
<form action= "select_like.php" method= "post";
<table class= "Search-tab";
<tr>
< Th width= ">": </th>
<td>
<select name= "Search-sort" id= "";
<option value= "" > all </option>
<option value= "+" > Sports fitness </option>
<option value= "A" > Travel </option
<option value= > Literary Art </option>
<option value= "A" > Speech </option>
<option "Value=" > Economic </option>,
<option value= "" > Movie </option>
<option value= "Up" > Technology < /option>,
<option value= "" > Gourmet </option>
</select>
</td>
<th width= "70" > Keywords: </th>
<td><input class= "common-text" placeholder= "keywords" name= "keywords" value= "" id= "" type = "text" ></TD>
<td><input class= "btn btn-primary btn2" name= "sub" value= "Query" type= "Submit" > </td>
</tr>
</table>
</form>
Controller:
<?php
Var_dump ($_post);
$con = mysql_connect ("localhost", ' root ', ' 12 ');
mysql_select_db (' News ', $con);
mysql_query (' Set names UTF8 ');
$arrAll = Array ();
if (!empty ($_post[' keywords ')) {
$keywords = $_post[' keywords ');
echo "SELECT * from Newsup where ' title ' like '%{$keywords}% '";
$result = mysql_query ("select * from Newsup where ' title ' like '%{$keywords}% '") or Die (' select Fail ');
while ($row = Mysql_fetch_assoc ($result)) {
$arrAll [] = $row;
}
}else{
$result = mysql_query ("SELECT * from Newsup") or Die (' select Fail ');
while ($row = Mysql_fetch_assoc ($result)) {
$arrAll [] = $row;
}
}
?>
PHP keywords Select