Jump to content

Drop Down--Search All feature


wabash

Recommended Posts

I have drop downs which are generated from fields in a database.  I'd like to implement an "Search All" selection into the dropdowns which searches all fields.  I'm wondering what the best way to do this is? 

Select Plant Color:<br />
	<select name="color">
<?php        
//for each row we get from mysql, echo a form input 
$querycolor="SELECT color FROM plantcolortable ORDER BY color";
$resultcolor = mysql_query ($querycolor);

while($rowcolor = mysql_fetch_array($resultcolor)){
echo "<option value=\"$rowcolor[color]\">$rowcolor[color]</option>\n"; 
}
?>
	</select>
</td>
<td width="400" valign="top">
Select Plant Exposure:<br />
<select name="exposure">
<?php
$queryexposure="SELECT exposure FROM plantexposuretable ORDER BY exposure";
$resultexposure = mysql_query ($queryexposure);
while($rowexposure = mysql_fetch_array($resultexposure)){
    echo "<option value=\"$rowexposure[exposure]\">$rowexposure[exposure]</option>\n";
}
?>

 

 

 

Below is what my query looks like:

 

<?php
$query = "SELECT actualplanttable.id, 
                        actualplanttable.common1,
		actualplanttable.scientific,
                        plantcolortable.color, 
                        plantexposuretable.exposure
                  FROM actualplanttable
                         JOIN plantcolorlinktable ON plantcolorlinktable.plant_id = actualplanttable.id
                                AND plantcolortable.color = '$color'
                         JOIN plantcolortable ON plantcolorlinktable.color_id = plantcolortable.id
                         JOIN plantexposurelinktable ON plantexposurelinktable.plant_id = actualplanttable.id
                         JOIN plantexposuretable ON plantexposurelinktable.exposure_id = plantexposuretable.id
                                 AND plantexposuretable.exposure = '$exposure' ORDER BY common1 ASC";
		$result = mysql_query($query) or die(mysql_error());

if($row = mysql_fetch_array($result))
{
		echo "<big>Deer Resistant plants Results that are <b>$color:</b></big><br><br> ";
		echo "<b>".$row['common1']."</b>  (". $row['scientific'].")<br> ";
		echo "Light Preference: ". $row['exposure']. "<br>"; 
		echo "A blooming color: ". $row['color'];
    	    echo "<br /><br />";

	while($row = mysql_fetch_array($result))
	{
		echo "<b>".$row['common1']."</b>  (". $row['scientific'].")<br> ";
		echo "Light Preference: ". $row['exposure']. "<br>"; 
		echo "A blooming color: ". $row['color'];
    	    echo "<br /><br />";
	}
}
else
{
	echo "No results found<br /><br />";
}
echo '<a href="http://www.website">Start a new Search</a>';
}

?>

 

 

Any help or guidance is greatly appreciated.  Thanks!

 

Bill...

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.