0

HI everyone, I have a problem with post
I want to do this in multi step and echo all data that I selected from drop down.
here my one page full code, then multi step page code.

full code

<?php
include('config.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script language="javascript" type="text/javascript">
function showState(Country_Id)
{
  document.frm.submit();
}

function showCity(State_Id)
{
  document.frm.submit();
}
</script>
</head>
<body>
<form action="page2.php" method="post" name="frm" id="frm">
<table width="500" border="0">
  <tr>
  <td width="119">Country</td>
  <td width="371">
  <select name="Country_id" id="Country_id" onChange="showState(this.value);">
  <option value="">--Select--</option>
  <?php
   $sql1="select * from country";
  $sql_row1=mysql_query($sql1);
  while($sql_res1=mysql_fetch_assoc($sql_row1))
  {
  ?>
  <option value="<?php echo $sql_res1["Country_Id"]; ?>" <?php if($sql_res1["Country_Id"]==$_REQUEST["Country_id"]) { echo "Selected"; } ?>><?php echo $sql_res1["CountryName"]; ?></option>
   <?php
   }
   ?>
  </select>
  </td>
  </tr>
  <tr>
  <td>State</td>
  <td id="td_state">
  <select name="state_id" id="state_id" onChange="showCity(this.value);">
  <option value="">--Select--</option>
  <?php
  $sql="select * from state where Country_Id='$_REQUEST[Country_id]'";
  $sql_row=mysql_query($sql);
  while($sql_res=mysql_fetch_assoc($sql_row))
  {
  ?>
  <option value="<?php echo $sql_res["StateId"]; ?>" <?php if($sql_res["StateId"]==$_REQUEST["state_id"]) { echo "Selected"; } ?>><?php echo $sql_res["StateName"]; ?></option>
  <?php
  }
  ?>
  </select>
  </td>
  </tr>
  <tr>
  <td>City</td>
  <td id="td_city">
    <select name="city_id" id="city_id">
    <option value="">--Select--</option>
    <?php
    $sql="select * from city where State_Id='$_REQUEST[state_id]'";
    $sql_row=mysql_query($sql);
    while($sql_res=mysql_fetch_assoc($sql_row))
    {
    ?>
    <option value="<?php echo $sql_res["State_Id"]; ?>"><?php echo $sql_res["CityName"]; ?></option>
    <?php
    }
    ?>
  </select>
    </td>
  </tr>
  <td>city grade</td>
  <td id="td_cityrade">
    <select name="citygrade_id" id="citygrade_id">
    <option value="">--Select--</option>
    <?php
    $sql="select * from citygrade where City_Id='$_REQUEST[c_id]ity'";
    $sql_row=mysql_query($sql);
    while($sql_res=mysql_fetch_assoc($sql_row))
    {
    ?>
    <option value="<?php echo $sql_res["City_Id"]; ?>"><?php echo $sql_res["Citygrade"]; ?></option>
    <?php
    }
    ?>
  </select>
    </td>
  </tr>
</table><input type="submit" name="submit" value="show" />
</form>
</body>
</html>

multi step
page1.php

<?php
include('config.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>page1</title>
<script language="javascript" type="text/javascript">
function showState(Country_id)
{
  document.form.submit();
}

function showCity(State_id)
{
  document.form.submit();
}
</script>
</head>
<body>
<div class="select">
<form name="form" method="post" action=""page2.php>
<select name="Country_id" id="Country_id" onChange="showState(this.value);">
  <option value="">--Select--</option>
  <?php
   $sql1="select * from country";
  $sql_row1=mysql_query($sql1);
  while($sql_res1=mysql_fetch_assoc($sql_row1))
  {
  ?>
  <option value="<?php echo $sql_res1["CountryName"]; ?>" <?php if($sql_res1["CountryName"]==$_REQUEST["Country_id"]) { echo "Selected"; } ?>><?php echo $sql_res1["CountryName"]; ?></option>
   <?php
   }
   ?>
  </select>
</form></div>
<input type="submit" name="submitstate" value="show state" />
</body>
</html>

page2.php

<?php
include('config.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>page2</title>
<script language="javascript" type="text/javascript">
function showState(Country_id)
{
  document.form.submit();
}

function showCity(State_id)
{
  document.form.submit();
}
</script>
</head>
<body>
<?php
$country = $_POST['Country_id'];
echo "the country you selected is ".$country;
?>
<form name="form" method="post" action=""page3.php"" >
<select name="state_id" id="state_id" onChange="showCity(this.value);">
  <option value="">--Select--</option>
  <?php
  $sql="select * from state where CountryName='$_REQUEST[Country_id]'";
  $sql_row=mysql_query($sql);
  while($sql_res=mysql_fetch_assoc($sql_row))
  {
  ?>
  <option value="<?php echo $sql_res["StateName"]; ?>" <?php if($sql_res["StateId"]==$_REQUEST["state_id"]) { echo "Selected"; } ?>><?php echo $sql_res["StateName"]; ?></option>
  <?php
  }
  ?>
  </select>
</form>
<input type="submit" name="submitstate" value="show state" />
</body>
</html>

page3.php

<?php
include('config.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>page3</title>
<script language="javascript" type="text/javascript">
function showCitygrade(City_id)
{
  document.form.submit();
}
</script>
</head>
<body>
<?php
$country = $_POST['Country_id'];
echo "the country you selected is ".$country;
echo "<br>";
$state = $_POST['state_id'];
echo "the state you selected is ".$state;
 $city = $_POST['city_id'];
echo "the state you selected is ".$city;
?>
<form name="form" method="post" action="page4.php" >
<select name="city_id" id="city_id" onChange="showCenterfloor(this.value);">
    <option value="">--Select--</option>
    <?php
    $sql="select * from city where StateName='$_REQUEST[state_id]'";
    $sql_row=mysql_query($sql);
    while($sql_res=mysql_fetch_assoc($sql_row))
    {
    ?>
    <option value="<?php echo $sql_res["CityId"]; ?>" <?php if($sql_res["CityId"]==$_REQUEST["city_id"]) { echo "Selected"; } ?>><?php echo $sql_res["CityName"]; ?></option>
    <?php
    }
    ?>
  </select>
</form>
<input type="submit" name="submitstate" value="submit" />
</body>
</html>

page4.php

I do the same as other page but it didn't work.

please help me,thanks for your time.

3
Contributors
3
Replies
22
Views
4 Years
Discussion Span
Last Post by Wailintun
0

Dumping 250 lines of code won't get you much help I don't think. How about you narrow down the problem for us and let us know where you're facing a problem.

0

Hello Wallintun,

please try to be a bit more descriptive: what is going wrong, what error message do you get?
also, what is it you're trying to achieve here, what do you mean by 'multi-step'?

and just as diafol said, try narrowing down your code. i'm seeing hunderds of lines and arent tempted to read through all of it.

0

Sorry! my mistake.I have problem with drop down when I choose drop down from page 1, it automatically go to page 2 without click on submit.This is error one.

Then I chose drop down from page 2 and go to page 3, page 1 data didn't show up in page 3.
I echo every data that I chose.this is error two.

Last error is in page 4, page 4 drop down do not show any data.

please help!
Thanks for your time.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.