MatesOnline
09-29-2004, 03:29 AM
Hi guys,
im having a problem with my code.
when a visitor searches for a member the query gets passed to another page & the DB is queried and results displayed
however the results aren't being displayed ( there are entries in the table )
here is my code for the search page
<form action="srchres.php" method="get" name="search" id="search">
<table width="318" border="0" cellspacing="0" cellpadding="0">
<tr bgcolor="#E33BE8" class="mediumtxt">
<td colspan="2"><div align="center"><strong><font color="#FFFFFF">Enter Criteria</font></strong> </div></td>
</tr>
<tr>
<td width="98" bgcolor="#FEB30A"><div align="left">Age : </div></td>
<td width="220" bgcolor="#E1E8F2"><div align="left">
<select name="age" class="mediumtxt" id="age">
<option value="*" selected>Any</option>
<option value="BETWEEN 13 AND 20">13 - 20</option>
<option value="BETWEEN 21 AND 30">21 - 30</option>
<option value="BETWEEN 31 AND 40">31 - 40</option>
<option value="BETWEEN 41 AND 50">41 - 50</option>
<option value="BETWEEN 51 AND 60">51 - 60</option>
<option value="61 >">60+</option>
</select>
</div></td>
</tr>
<tr>
<td bgcolor="#FEB30A"><div align="left">Sex : </div></td>
<td bgcolor="#E1E8F2"><div align="left">
<select name="sex" class="mediumtxt" id="sex">
<option value="Male" selected>Male</option>
<option value="Female">Female</option>
</select>
</div></td>
</tr>
<tr>
<td bgcolor="#FEB30A"><div align="left">Country : </div></td>
<td bgcolor="#E1E8F2"><div align="left">
<select name="country" class="mediumtxt" id="country">
<option value="*">Any</option>
<option value="United Kingdom" selected>UK</option>
<option value="United States">United States</option>
//Reduced for post </select>
</div></td>
</tr>
<tr>
<td bgcolor="#FEB30A"><div align="left">Sexuality : </div></td>
<td bgcolor="#E1E8F2"><div align="left">
<select name="sexuality" class="mediumtxt" id="sexuality">
<option value="*" selected>Any</option>
<option value="Straight">Straight</option>
<option value="Bi-sexual">Bi-sexual</option>
<option value="Open Minded">Open Minded</option>
<option value="Gay / Lesbian">Gay / Lesbian</option>
<option value="Rather Not Say">Rather Not Say</option>
</select>
</div></td>
</tr>
<tr>
<td bgcolor="#FEB30A"><div align="left">Race : </div></td>
<td bgcolor="#E1E8F2"><div align="left">
<select name="race" class="mediumtxt" id="race">
<option value="*" selected>Any</option>
<option value="Asian">Asian</option>
<option value="Latin / Hispanic">Latin / Hispanic</option>
<option value="Mixed Race">Mixed Race</option>
<option value="White European">White European</option>
<option value="Oriental">Oriental</option>
<option value="African American">African American</option>
</select>
</div></td>
</tr>
<tr>
<td bgcolor="#FEB30A"><div align="left">Body Type : </div></td>
<td bgcolor="#E1E8F2"><div align="left">
<select name="body_type" class="mediumtxt" id="body_type">
<option value="*" selected>Not Bothered</option>
<option value="Slim / Toned" >Slim / Toned</option>
<option value="Average" >Average</option>
<option value="Defined" >Defined</option>
<option value="Medium Build" >Medium Build</option>
<option value="Fuller Figure" >Fuller Figure</option>
</select>
</div></td>
</tr>
<tr>
<td bgcolor="#FEB30A"><div align="left">Marital Status : </div></td>
<td bgcolor="#E1E8F2"><div align="left">
<select name="marital_status" class="mediumtxt" id="marital_status">
<option value="*" selected>Any</option>
<option value="Single">Single</option>
<option value="In Relationship" >In Relationship</option>
<option value="Engaged" >Engaged</option>
<option value="Happily Married" >Happily Married</option>
<option value="Unhappily Married" >Unhappily Married</option>
<option value="Divorced" >Divorced</option>
<option value="Widowed" >Widowed</option>
</select>
</div></td>
</tr>
</table>
<br>
<input type="submit" class="smalltxt" value="Search">
</form>
and here is the code for the database query on the srchres.php page
$sex = $_GET['sex'];
$country = $_GET['country'];
$newcountry = str_replace('+', '', $country);
$sexuality = $_GET['sexuality'];
$race = $_GET['race'];
$body_type = $_GET['body_type'];
$marital_status = $_GET['marital_status'];
$maxRows_memberprofile = 10;
$pageNum_memberprofile = 0;
if (isset($_GET['pageNum_memberprofile'])) {
$pageNum_memberprofile = $_GET['pageNum_memberprofile'];
}
$startRow_memberprofile = $pageNum_memberprofile * $maxRows_memberprofile;
mysql_select_db($database_OnlineFlirting, $OnlineFlirting);
$query_memberprofile = "SELECT * FROM members WHERE sex='$sex' AND country='$newcountry' AND sexuality='$sexuality' AND race='$race' AND body_type='$body_type' AND marital_status='$marital_status' AND age ".$_GET['age'];
$query_limit_memberprofile = sprintf("%s LIMIT %d, %d", $query_memberprofile, $startRow_memberprofile, $maxRows_memberprofile);
$memberprofile = mysql_query($query_limit_memberprofile, $OnlineFlirting) or die(mysql_error());
$row_memberprofile = mysql_fetch_assoc($memberprofile);
if (isset($_GET['totalRows_memberprofile'])) {
$totalRows_memberprofile = $_GET['totalRows_memberprofile'];
} else {
$all_memberprofile = mysql_query($query_memberprofile);
$totalRows_memberprofile = mysql_num_rows($all_memberprofile);
}
$totalPages_memberprofile = ceil($totalRows_memberprofile/$maxRows_memberprofile)-1;
and here is the code that displays the results ( still on srchres.php )
<td rowspan="5" valign="top" class="mediumtxt1">
<div align="center"> <table width="102" height="237" border="0" cellpadding="0" cellspacing="0">
<tr>
<?php do { ?>
<td width="102"><?php
if($row_memberprofile['ppic']=="Not Set"){
$displaypic = "<img src=\"upload/nopicsml.jpg\" width=\"30\" height=\"30\">";
} else {
$displaypic = "<img src=\"$row_memberprofile[ppic]\" width=\"100\" height=\"100\">";;
}
?>
<?php echo $displaypic;?>
<?php echo $row_memberprofile['username']; ?> </td>
<?php } while ($row_memberprofile = mysql_fetch_assoc($memberprofile)); ?>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><a href="<?php printf("%s?pageNum_memberprofile=%d%s", $currentPage, max(0, $pageNum_memberprofile - 1), $queryString_memberprofile); ?>" class="mediumtxt"><font color="#CC0000">Previous</font></a> | <a href="<?php printf("%s?pageNum_memberprofile=%d%s", $currentPage, min($totalPages_memberprofile, $pageNum_memberprofile + 1), $queryString_memberprofile); ?>" class="mediumtxt"><font color="#CC0000">Next</font></a></td>
</tr>
</table>
any ideas guys ? Im stumped :(
im having a problem with my code.
when a visitor searches for a member the query gets passed to another page & the DB is queried and results displayed
however the results aren't being displayed ( there are entries in the table )
here is my code for the search page
<form action="srchres.php" method="get" name="search" id="search">
<table width="318" border="0" cellspacing="0" cellpadding="0">
<tr bgcolor="#E33BE8" class="mediumtxt">
<td colspan="2"><div align="center"><strong><font color="#FFFFFF">Enter Criteria</font></strong> </div></td>
</tr>
<tr>
<td width="98" bgcolor="#FEB30A"><div align="left">Age : </div></td>
<td width="220" bgcolor="#E1E8F2"><div align="left">
<select name="age" class="mediumtxt" id="age">
<option value="*" selected>Any</option>
<option value="BETWEEN 13 AND 20">13 - 20</option>
<option value="BETWEEN 21 AND 30">21 - 30</option>
<option value="BETWEEN 31 AND 40">31 - 40</option>
<option value="BETWEEN 41 AND 50">41 - 50</option>
<option value="BETWEEN 51 AND 60">51 - 60</option>
<option value="61 >">60+</option>
</select>
</div></td>
</tr>
<tr>
<td bgcolor="#FEB30A"><div align="left">Sex : </div></td>
<td bgcolor="#E1E8F2"><div align="left">
<select name="sex" class="mediumtxt" id="sex">
<option value="Male" selected>Male</option>
<option value="Female">Female</option>
</select>
</div></td>
</tr>
<tr>
<td bgcolor="#FEB30A"><div align="left">Country : </div></td>
<td bgcolor="#E1E8F2"><div align="left">
<select name="country" class="mediumtxt" id="country">
<option value="*">Any</option>
<option value="United Kingdom" selected>UK</option>
<option value="United States">United States</option>
//Reduced for post </select>
</div></td>
</tr>
<tr>
<td bgcolor="#FEB30A"><div align="left">Sexuality : </div></td>
<td bgcolor="#E1E8F2"><div align="left">
<select name="sexuality" class="mediumtxt" id="sexuality">
<option value="*" selected>Any</option>
<option value="Straight">Straight</option>
<option value="Bi-sexual">Bi-sexual</option>
<option value="Open Minded">Open Minded</option>
<option value="Gay / Lesbian">Gay / Lesbian</option>
<option value="Rather Not Say">Rather Not Say</option>
</select>
</div></td>
</tr>
<tr>
<td bgcolor="#FEB30A"><div align="left">Race : </div></td>
<td bgcolor="#E1E8F2"><div align="left">
<select name="race" class="mediumtxt" id="race">
<option value="*" selected>Any</option>
<option value="Asian">Asian</option>
<option value="Latin / Hispanic">Latin / Hispanic</option>
<option value="Mixed Race">Mixed Race</option>
<option value="White European">White European</option>
<option value="Oriental">Oriental</option>
<option value="African American">African American</option>
</select>
</div></td>
</tr>
<tr>
<td bgcolor="#FEB30A"><div align="left">Body Type : </div></td>
<td bgcolor="#E1E8F2"><div align="left">
<select name="body_type" class="mediumtxt" id="body_type">
<option value="*" selected>Not Bothered</option>
<option value="Slim / Toned" >Slim / Toned</option>
<option value="Average" >Average</option>
<option value="Defined" >Defined</option>
<option value="Medium Build" >Medium Build</option>
<option value="Fuller Figure" >Fuller Figure</option>
</select>
</div></td>
</tr>
<tr>
<td bgcolor="#FEB30A"><div align="left">Marital Status : </div></td>
<td bgcolor="#E1E8F2"><div align="left">
<select name="marital_status" class="mediumtxt" id="marital_status">
<option value="*" selected>Any</option>
<option value="Single">Single</option>
<option value="In Relationship" >In Relationship</option>
<option value="Engaged" >Engaged</option>
<option value="Happily Married" >Happily Married</option>
<option value="Unhappily Married" >Unhappily Married</option>
<option value="Divorced" >Divorced</option>
<option value="Widowed" >Widowed</option>
</select>
</div></td>
</tr>
</table>
<br>
<input type="submit" class="smalltxt" value="Search">
</form>
and here is the code for the database query on the srchres.php page
$sex = $_GET['sex'];
$country = $_GET['country'];
$newcountry = str_replace('+', '', $country);
$sexuality = $_GET['sexuality'];
$race = $_GET['race'];
$body_type = $_GET['body_type'];
$marital_status = $_GET['marital_status'];
$maxRows_memberprofile = 10;
$pageNum_memberprofile = 0;
if (isset($_GET['pageNum_memberprofile'])) {
$pageNum_memberprofile = $_GET['pageNum_memberprofile'];
}
$startRow_memberprofile = $pageNum_memberprofile * $maxRows_memberprofile;
mysql_select_db($database_OnlineFlirting, $OnlineFlirting);
$query_memberprofile = "SELECT * FROM members WHERE sex='$sex' AND country='$newcountry' AND sexuality='$sexuality' AND race='$race' AND body_type='$body_type' AND marital_status='$marital_status' AND age ".$_GET['age'];
$query_limit_memberprofile = sprintf("%s LIMIT %d, %d", $query_memberprofile, $startRow_memberprofile, $maxRows_memberprofile);
$memberprofile = mysql_query($query_limit_memberprofile, $OnlineFlirting) or die(mysql_error());
$row_memberprofile = mysql_fetch_assoc($memberprofile);
if (isset($_GET['totalRows_memberprofile'])) {
$totalRows_memberprofile = $_GET['totalRows_memberprofile'];
} else {
$all_memberprofile = mysql_query($query_memberprofile);
$totalRows_memberprofile = mysql_num_rows($all_memberprofile);
}
$totalPages_memberprofile = ceil($totalRows_memberprofile/$maxRows_memberprofile)-1;
and here is the code that displays the results ( still on srchres.php )
<td rowspan="5" valign="top" class="mediumtxt1">
<div align="center"> <table width="102" height="237" border="0" cellpadding="0" cellspacing="0">
<tr>
<?php do { ?>
<td width="102"><?php
if($row_memberprofile['ppic']=="Not Set"){
$displaypic = "<img src=\"upload/nopicsml.jpg\" width=\"30\" height=\"30\">";
} else {
$displaypic = "<img src=\"$row_memberprofile[ppic]\" width=\"100\" height=\"100\">";;
}
?>
<?php echo $displaypic;?>
<?php echo $row_memberprofile['username']; ?> </td>
<?php } while ($row_memberprofile = mysql_fetch_assoc($memberprofile)); ?>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><a href="<?php printf("%s?pageNum_memberprofile=%d%s", $currentPage, max(0, $pageNum_memberprofile - 1), $queryString_memberprofile); ?>" class="mediumtxt"><font color="#CC0000">Previous</font></a> | <a href="<?php printf("%s?pageNum_memberprofile=%d%s", $currentPage, min($totalPages_memberprofile, $pageNum_memberprofile + 1), $queryString_memberprofile); ?>" class="mediumtxt"><font color="#CC0000">Next</font></a></td>
</tr>
</table>
any ideas guys ? Im stumped :(