<?php
extract( $_GET );
$sql = "SELECT * FROM tablename order by Name DESC";
$sql = "SELECT * FROM tablename where age = "31";
$db = mysql_connect("localhost","root","password");
if (!$db) {
die("");
}
$db_select = mysql_select_db('databasename',$db);
if (!$db_select) {
die("");
}
if ( !( $result = mysql_query( $sql, $db ) ) ) {
print( "Could not execute query! <br />" );
die( mysql_error() . "</body></html>" );
} // end if
echo "<table>
<tr>
<th>Name</th>
<th>Age</th>
</tr>";
while($row = mysql_fetch_array($result)){
echo "<tr>";
echo "<td>".$row['Name']."</td>";
echo "<td>".$row['Age']."</td>";
}
echo "</table>";
mysql_close( $db );
?>
Where should I add an if else statement for name and age that runs the sql statement when either the name or age is selected? Name and Age is from different column but in the same table