Forum Moderators: coopster
Now I need to put a second search parameter on the same search form (this will be an either/or option....i.e. search for one or search for the other). Try as I might I can't get the second search to produce results. I get a blank page. Can someone look at the code and tell me what I'm doing wrong? I know it's some horribly stupid newbie mistake. (I'm designing in DWMX if that's any help providing an answer)
Heres the code for the search.php
<?php require_once('Connections/members.php');?>
<?php
mysql_select_db($database_members, $members);
$query_Recordset1 = "SELECT * FROM members";
$Recordset1 = mysql_query($query_Recordset1, $members) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form action="results.php" method="post" name="searchform" id="searchform">
<table width="100%" border="0" cellspacing="2" cellpadding="2">
<tr>
<td width="26%"><div align="right">Search by Name </div></td>
<td width="20%"><input name="name" type="text" id="name"></td>
<td width="54%"> </td>
</tr>
<tr>
<td><div align="right">Search By Province </div></td>
<td><select name="province" id="province">
<option value="">Select</option>
<?php
do {
?>
<option value="<?php echo $row_Recordset1['Province']?>"><?php echo $row_Recordset1['Province']?></option>
<?php
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
$rows = mysql_num_rows($Recordset1);
if($rows > 0) {
mysql_data_seek($Recordset1, 0);
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
}
?>
</select></td>
<td> </td>
</tr>
<tr>
<td><div align="right">Search By Specialty </div></td>
<td><select name="specialty" id="specialty">
<option value="">Select</option>
<?php
do {
?>
<option value="<?php echo $row_Recordset1['Specialty']?>"><?php echo $row_Recordset1['Specialty']?></option>
<?php
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
$rows = mysql_num_rows($Recordset1);
if($rows > 0) {
mysql_data_seek($Recordset1, 0);
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
}
?>
</select></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Submit"></td>
<td> </td>
</tr>
</table>
</form>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
/////////////////////////////////////////
and here's the code for the results.php
<?php require_once('Connections/members.php');?>
<?php
mysql_select_db($database_members, $members);
$query_Recordset1 = "SELECT * FROM members";
$Recordset1 = mysql_query($query_Recordset1, $members) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form action="results.php" method="post" name="searchform" id="searchform">
<table width="100%" border="0" cellspacing="2" cellpadding="2">
<tr>
<td width="26%"><div align="right">Search by Name </div></td>
<td width="20%"><input name="name" type="text" id="name"></td>
<td width="54%"> </td>
</tr>
<tr>
<td><div align="right">Search By Province </div></td>
<td><select name="province" id="province">
<option value="">Select</option>
<?php
do {
?>
<option value="<?php echo $row_Recordset1['Province']?>"><?php echo $row_Recordset1['Province']?></option>
<?php
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
$rows = mysql_num_rows($Recordset1);
if($rows > 0) {
mysql_data_seek($Recordset1, 0);
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
}
?>
</select></td>
<td> </td>
</tr>
<tr>
<td><div align="right">Search By Specialty </div></td>
<td><select name="specialty" id="specialty">
<option value="">Select</option>
<?php
do {
?>
<option value="<?php echo $row_Recordset1['Specialty']?>"><?php echo $row_Recordset1['Specialty']?></option>
<?php
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
$rows = mysql_num_rows($Recordset1);
if($rows > 0) {
mysql_data_seek($Recordset1, 0);
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
}
?>
</select></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Submit"></td>
<td> </td>
</tr>
</table>
</form>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
To display the result in a table rows on the results page, you need to loop through the table rows and your database results, which is basically missing in yours.
Try something like the following:
<?php
echo "<table border=0 cellpadding=1 cellspacing=0>\n";
while($C = mysql_fetch_array($result)){
echo " <tr>\n"
. "<td height=\"85\" align=center valign=middle>"
. $C['title']
. "</td>\n"
. "</tr>\n"
}
echo "</table>";
?>
Habtom