Ok so I made this code that is searching thru a database with names and such, and if you enter a name like john and age 20, but there is no john that is 20 in the database it shows all the johns and so on with age if there is no john it shows all the people that are 20, well I think you get it.
BUT, if all fields aren’t filled in with something it shows all the persons in the database, so I would need a little bit of help…
This is the code:
[code]if(isset($_POST[‘screenname’])) {$a = mysql_query(“SELECT * FROM Persons WHERE ScreenName LIKE ‘%$_POST[screenname]%’”); }
if(isset($_POST[‘firstname’])) {$b = mysql_query(“SELECT * FROM Persons WHERE Firstname LIKE ‘%$_POST[firstname]%’”); }
if(isset($_POST[‘lastname’])) {$c = mysql_query(“SELECT * FROM Persons WHERE LastName LIKE ‘%$_POST[lastname]%’”); }
if(isset($_POST[‘age’])) {$d = mysql_query(“SELECT * FROM Persons WHERE Age LIKE ‘%$_POST[age]%’”); }
if(isset($_POST[‘country’])) {$e = mysql_query(“SELECT * FROM Persons WHERE Country LIKE ‘%$_POST[country]%’”); }
if(isset($_POST[‘other’])) {$f = mysql_query(“SELECT * FROM Persons WHERE Other LIKE ‘%$_POST[other]%’”); }
while($rowa = mysql_fetch_array($a))
{
echo $rowa[‘ScreenName’] . " " . $rowa[‘FirstName’] . " " . $rowa[‘LastName’]. " " . $rowa[‘Age’]. " " . $rowa[‘Country’]. " " . $rowa[‘Other’];
echo “
”;
}
while($rowb = mysql_fetch_array($b))
{
echo $rowb[‘ScreenName’] . " " . $rowb[‘FirstName’] . " " . $rowb[‘LastName’]. " " . $rowb[‘Age’]. " " . $rowb[‘Country’]. " " . $rowb[‘Other’];
echo “
”;
}
while($rowc = mysql_fetch_array($c))
{
echo $rowc[‘ScreenName’] . " " . $rowc[‘FirstName’] . " " . $rowc[‘LastName’]. " " . $rowc[‘Age’]. " " . $rowc[‘Country’]. " " . $rowc[‘Other’];
echo “
”;
}
while($rowd = mysql_fetch_array($d))
{
echo $rowd[‘ScreenName’] . " " . $rowd[‘FirstName’] . " " . $rowd[‘LastName’]. " " . $rowd[‘Age’]. " " . $rowd[‘Country’]. " " . $rowd[‘Other’];
echo “
”;
}
while($rowe = mysql_fetch_array($e))
{
echo $rowe[‘ScreenName’] . " " . $rowe[‘FirstName’] . " " . $rowe[‘LastName’]. " " . $rowe[‘Age’]. " " . $rowe[‘Country’]. " " . $rowe[‘Other’];
echo “
”;
}
while($rowf = mysql_fetch_array($f))
{
echo $rowf[‘ScreenName’] . " " . $rowf[‘FirstName’] . " " . $rowf[‘LastName’]. " " . $rowf[‘Age’]. " " . $rowf[‘Country’]. " " . $rowf[‘Other’];;
echo “
”;
}[/code]