Auto-populating dropdowns and multiple forms.
Posted on
16th Feb 2014 07:03 pm by
admin
Here's what I have so far:
First drop down = select a state (works)
This populates the second drop down (works)
Second drop down = select a city (works)
This populates the third drop down with local restaurant names (not quite)
When I select a restaurant from the drop down the form is submitted but the $rest_name variable isn't carried over
Site: www.abcgreatdeals.com
Select:California, La Quinta for an example
I'm sure it's something simple that I'm just over looking. Thanks for any input.
Code: [Select]<form id="form1" name="form1" method="post" action="<?php echo $PHP_SELF; ?>" enctype="multipart/form-data">
<?php
if (isset ($_POST['state']))
{
if ($state == '99')
{
?>
<script type="text/javascript">
<!--
window.location = "http://www.abcgreatdeals.com"
//-->
</script>
<?php
}
?>
<select name="state" CLASS="formTextbox" onchange="form1.submit();">
<option value="<?=$state;?>"><?=$state;?></option>
<option value="99">Start Over</option>
<?php
}
else{
$Get_State = mysql_query("SELECT DISTINCT state FROM coupons ORDER BY state",$db_link);
?>
<select name="state" CLASS="formTextbox" onchange="this.form.submit();">
<OPTION SELECTED VALUE="">Select A State</OPTION>
<? while($get_it = mysql_fetch_array($Get_State)) { ?>
<option value="<?=$get_it['state'];?>"><?=$get_it['state'];?></option>
<?
}}
if (isset ($_POST['state']))
{?>
</select>
</form>
<form id="form2" name="form2" method="post" action="<?php echo $PHP_SELF; ?>" enctype="multipart/form-data">
<?php
if (isset ($_POST['city']) != '')
{
if ($city == '99')
{
?>
<script type="text/javascript">
<!--
window.location = "http://www.abcgreatdeals.com"
//-->
</script>
<?php
}
?>
<input type="hidden" name="state" value="<?="$state"; ?>">
<select name="city" CLASS="formTextbox" onchange="form2.submit();">
<option value="<?=$city;?>"><?=$city;?></option>
<option value="99">Start Over</option>
<?php
}
else{
$Got_City = mysql_query("SELECT DISTINCT city FROM coupons WHERE state='$state' ORDER BY city",$db_link);
?>
<input type="hidden" name="state" value="<?="$state"; ?>">
<select name="city" CLASS="formTextbox" onchange="form2.submit();">
<OPTION SELECTED VALUE="">Select A City</OPTION>
<? while($got_it = mysql_fetch_array($Got_City)) { ?>
<?
if ($got_it['city'] != ''){ ?>
<option value="<?=$got_it['city'];?>"><?=$got_it['city'];?></option>
<?
}
else { ?>
<option value="99">Start Over</option>
<? } ?>
<?
}}
if (isset ($_POST['city']))
{?>
</select>
</form>
<form id="form3" name="form3" method="post" action="<?php echo $PHP_SELF; ?>" enctype="multipart/form-data">
<?php
if (isset ($_POST['rest']) != '')
{
if ($rest == '99')
{
?>
<script type="text/javascript">
<!--
window.location = "http://www.abcgreatdeals.com"
//-->
</script>
<?php
}
?>
<input type="hidden" name="city" value="<?="$city"; ?>">
<input type="hidden" name="state" value="<?="$state"; ?>">
<select name="rest" CLASS="formTextbox" onchange="form3.submit();">
<option value="<?=$rest_name;?>"><?=$rest_name?></option>
<option value="99">Start Over</option>
<?php
}
else{
$Get_Rest = mysql_query("SELECT DISTINCT rest_name FROM coupons WHERE state='$state' AND city='$city'",$db_link);
?>
<input type="hidden" name="state" value="<?=$state?>">
<input type="hidden" name="city" value="<?=$city?>">
<select name="rest" CLASS="formTextbox" onchange="form3.submit();">
<OPTION SELECTED VALUE="">Select A Restaurant</OPTION>
<?
while($got_rest = mysql_fetch_array($Get_Rest)){
$rest_name = stripslashes($got_rest['rest_name']);
?>
<option value="<?=$rest_name;?>"><?=$rest_name?></option>
<?
}}}}
if (isset ($_POST['rest']))
{?>
</select>
</form>
<?php
if ($rest_name){
echo "<strong>Click on coupons to print individually</strong>
";
}
if ($rest_name)
{
$Get_Coupons = mysql_query("SELECT * FROM coupons WHERE rest_name='$rest_name' ORDER BY coupon_rank DESC",$db_link);
No comments posted yet
Your Answer:
Login to answer
83
20
Other forums
Sub-domains & calling unique content
Hello,
Is there a way use something similar to the $_GET function for a sub-domain? I to be a
mail with attachment problems
Hi. I have the following code:
Code: else if(file_exists("site".$timp.".zip")
Adding meta tags under Zend FW
Hello there, recently has come to my hands the FTP of a website which is running under Zend, I would
how do i make new line after *
First check this page here. and you see my report. Im pulling form a mysql db. I want to beable to m
I have a parse error in this query help..
Code: $query1="INSERT INTO `rating` (`item_name`, `rating`, `ip_address`, `date_rated`) VALUES
want a code for uploading and downloading
i m trying to upload and download to my site..i need upload and download code ...i use a code for up
Retreiving objects from Sessions
Hi all,
I am getting really frustrated with storing and retreiving objects from a session. Bu
records between 2 dates
Hello all,
I have a date tracked table which contains effective_start_date and effective
Cant display mysql data
Hey all,
I am learning php and my first goal is to create a simple CMS. At the moment I am st
admin with my register system?
Hey i wana make it so i can make a admin level on my register system , I'm kinda new to php to im no