php question fetching value?

Mit Chauhan

New member
JAI MATADI all . .

m working in a simple programme in php where i want to fetch the result from mysql database using php to my website ..

what i want is if the user selects the GENDER the results should come accordingly which are available in the database according to their GENDER ..

but m getting problem in this ..

here is my code ..

-----------------------------------------------------
<form method="post" name="form1">

Select Gender :
<input type="radio" name="g1" value="Male" checked="checked" />Male
<input type="radio" name="g1" value="Female" />Female

<br />
<input type="submit" name="submit" value="Search" />

</form>

<?php

if (isset($_POST["submit"]))
{
//echo "hello";
$gender = $_POST["g1"];
mysql_connect("localhost","root","");
mysql_select_db("alldatabase");
$qry = "select * from signup where pgender='$gender'";
$rs = mysql_query($qry);
if(!mysql_query($qry))
{
echo mysql_error();
}
if($rows = mysql_fetch_array($rs))
{
//echo "value fetching";
$fullname = $rows["pname"];
echo $fullname;
}
else
{
echo "value not fetching";
}
}

?>
------------------
-----------------------------------------------------

but here what problem m facing is m getting the first record only which is in my database .. not the second if it is there and so on .. m getting the first record only ..

whats wrong m doing here .. please php masters help me out if you can ..

thank you . .
 
Back
Top