Search Form
Posted: Tue Apr 22, 2008 8:09 am
hi guys, creating a search form and im having difficulties getting the selected city or subcategory to submit so that the search form displays which city and/or subcategory the user selects. the code in question is as follows, and parts of it are incorrect I know, but its the only way I can get the form to load (even though the form itself doesnt actually work!)
can someone point out to me where am I going wrong? do i need to put "selected" somewhere?
Code: Select all
<form action="?" method="get">
<input type="hidden" name="cityid" value="<?php echo $xcityid; ?>">
<input type="hidden" name="lang" value="<?php echo $xlang; ?>">
<input name="search" type="text" size="<?php echo $searchbox_on_top?35:23; ?>" value="<?php echo $_GET['search']; ?>">
<?php
if ($xsubcatid > 0)
{
?>
<?php echo $field_sep; ?>
<select name="cities">
<?php
$sql = "SELECT countryid, cityname AS cityname
FROM $t_cities
WHERE enabled = '1'
ORDER BY countryid";
$cityres = mysql_query($sql);
while ($row=mysql_fetch_array($cityres))
{
echo "<option value=\"$row[countryid]\">$row[cityname]</option>\n";
if ($_GET['cities'] == $row['cityname']) echo " selected";
}
?>
</select>
<input type="hidden" name="view" value="ads">
<input type="hidden" name="cities" value="<?php echo $_GET['selected']; ?>">
<?php echo $field_sep; ?>
<select name="subcatname">
<?php
$sql = "SELECT subcatid, subcatname AS subcatname
FROM $t_subcats scat
WHERE enabled = '1'
ORDER BY subcatid";
$scatres = mysql_query($sql);
while ($row=mysql_fetch_array($scatres))
{
echo "<option value=\"$row[subcatid]\">$row[subcatname]</option>\n";
}
?>
</select>
<input type="hidden" name="view" value="ads">
<input type="hidden" name="subcatid" value="<?php echo $row[subcatname]; ?>">