Good evening everyone. (Manila Time). ?
I have a question regarding searching the mysql database with the use of PHP. I have a code that searches for a specific output. Now it works fine when searching on one column. I searched for the position applied of the user. It works. Now I want my search to have another entry which is age. I want it to be on condition with the first.
[code=php]//form.php
<form method=”post” action=”search.php”>
<select name=”search”>
<option value=”Secretary”>Secretary</option>
<option value=”Accountant”>Accountant</option>
</select>
<input type=”text” name=”age” value=”” />
<input type=”Submit” name=”Submit” value=”Submit”>
</form>
[code=php]//search.php
<?php
require_once(‘admin_authenticate.php’);
include ‘db_connect.php’;
$search=$_POST[‘search’];
$age = $_POST[‘age’];
$result = mysql_query(“SELECT * FROM users WHERE position_applied LIKE ‘%$search%'”);
echo “The system found ” . mysql_num_rows($result) . ” results.” . “<br />”;
while($r=mysql_fetch_array($result))
{
$id = $r[‘id’];
$position = $r[‘position_applied’];
$username = $r[‘username’];
$emailadd = $r[’emailadd’];
$firstname = $r[‘firstname’];
$midname = $r[‘midname’];
$lastname = $r[‘lastname’];
echo “<b>Position Applied :</b>” . ” ” . $position . “<br />”;
echo “<b>Username :</b>” . ” ” . $username . “<br />”;
echo “<b>Email Address :</b>” . ” ” . $emailadd . “<br />”;
echo “<b>Name :</b>” . ” ” . $firstname . ” ” . $midname . ” ” . $lastname . “<br />”;
echo “<br />”;
}
?>
The script above works. However I want to display only those records who have an age greater than the one I will input on the text field. How is it?