Skip to content

Instantly share code, notes, and snippets.

@dcblogdev
Last active January 16, 2022 02:52
Show Gist options
  • Save dcblogdev/5679793 to your computer and use it in GitHub Desktop.
Save dcblogdev/5679793 to your computer and use it in GitHub Desktop.
filter search example
<?php
if(isset($_GET['submit'])){
extract($_POST);
if(!empty($subject)){ $extra.= " AND subject = '$subject'"; }
if(!empty($id)){ $extra.= " AND id = '$id'"; }
if(!empty($FirstName)){ $extra.= " AND FirstName = '$FirstName'"; }
if(!empty($LastName)){ $extra.= " AND LastName = '$LastName'"; }
if(!empty($address)){ $extra.= " AND address = '$address'"; }
$q = mysql_query("SELECT * FROM table WHERE id $extra");
$r = while($row = mysql_fetch_object($q)){
//display result here like:
echo $row->subject;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment