Typically your SQL query would be based on variables you got through GET or POST type actions.
for example: myhost.com/doit.php?suburb=Tenafly&gender=M
<?
//file doit.php
$suburb=$GET['suburb'];
$gender=$GET['gender'];
//insert your database connect stuff here...
$result=mysql_query("SELECT *
FROM rego
WHERE suburb = '$suburb' AND gender = '$gender'
"
);
//now fetch the resulting rows SELECTED by the query
while($row=mysql_fetch_array($result)){
//do something with the array;
foreach($row as $value){echo $value;}
}
?>