Hey everyone!
Still working on a site I posted for a while ago. Essentially I have a search function that is populated through by a database in mySQL and PHP. I need a few things to help the finishing touches on this...
I need to have a "select all" option in each pulldown menu that will select all rows, and pass them onto the next page so that they can still be selected. Hopefully this makes sense.
Here is the code for the first page (after connecting to the database):
[PHP]<form method="POST" action="search2.php"> Type of Listing: <select name="type">
<?php $sql = mysql_query("SELECT DISTINCT type FROM listings WHERE state LIKE '$state' ORDER BY type ASC"); while ($row = mysql_fetch_array($sql)) { ?>
<option name="<?php echo $row['type']; ?>" id="<?php echo $row['type']; ?>"> <?php echo $row['type']; ?> </option> <?php } ?>
</select>
<input type="submit" value="Continue Search"></form>[/PHP]
Code for the second page:
[PHP]<form method="POST" action="results.php"> Type of Listing: <select name="type">
<?php $sql = mysql_query("SELECT DISTINCT type FROM listings WHERE type LIKE '$type'"); while ($row = mysql_fetch_array($sql)) { ?>
<option name="<?php echo $type; ?>" id="<?php echo $type; ?>"> <?php echo $type; ?> </option> <?php } ?></select>
<br><br>
Area/Location:<select name="area">
<?php $sql = mysql_query("SELECT DISTINCT area FROM listings WHERE type LIKE '$type' ORDER BY area ASC"); while ($row = mysql_fetch_array($sql)) { ?>
<option name="<?php echo $row['area']; ?>" id="<?php echo $row['area']; ?>"> <?php echo $row['area']; ?> </option> <?php } ?></select>
<input name="" type="submit" value="Display Listings"></form>[/PHP]
Here is the results page:
[PHP]<?php
$query="SELECT * FROM listings WHERE area LIKE '$area' AND type LIKE '$type'";
$result=mysql_query($query);
$num=mysql_numrows($result);
echo "<p class='purple_text' align='center'><b>Results for $type in $area</b></p>";
mysql_close();
$i=0;
while ($i < $num) {
$type=mysql_result($result,$i,"type");
$area=mysql_result($result,$i,"area");
$name=mysql_result($result,$i,"name");
$content=mysql_result($result,$i,"content");
$address=mysql_result($result,$i,"address");
if ($name != "") { echo "<hr width='50%'><p align='center'><b>$name</b>"; }
if ($content != "") { echo "<br><i>$content</i>"; }
if ($address != "") { echo "<br>$address"; }
$i++;
}
?>[/PHP]
Thank you so much!