Jump to content

select menu to show record selected on same page


jonnyfortis
Go to solution Solved by mac_gyver,

Recommended Posts

I have dynamic select list that is populated with countries (each country has information (shops) that is associated it. When the country is selected i want the shop information to show below then menu.

 

the statement for the shop is

mysql_select_db($database_beau, $beau);
$query_rsStockists = "SELECT * FROM beauAW13_stockist, beauAW13_stockistLoc WHERE beauAW13_stockist.stockistLocID = beauAW13_stockistLoc.stockistLocID";
$rsStockists = mysql_query($query_rsStockists, $beau) or die(mysql_error());
$row_rsStockists = mysql_fetch_assoc($rsStockists);
$totalRows_rsStockists = mysql_num_rows($rsStockists);
 
mysql_select_db($database_beau, $beau);
$query_rsCountries = "SELECT * FROM beauAW13_stockistLoc";
$rsCountries = mysql_query($query_rsCountries, $beau) or die(mysql_error());
$row_rsCountries = mysql_fetch_assoc($rsCountries);
$totalRows_rsCountries = mysql_num_rows($rsCountries);

the select list is

 <form id="form1" name="form1" method="post" action="">
    <label for="select"></label>
    <select name="select" id="select">
      <?php
do { 
?>
      <option value="<?php echo $row_rsCountries['stockistLocID']?>"><?php echo $row_rsCountries['stockistLocName']?></option>
      <?php
} while ($row_rsCountries = mysql_fetch_assoc($rsCountries));
  $rows = mysql_num_rows($rsCountries);
  if($rows > 0) {
      mysql_data_seek($rsCountries, 0);
            $row_rsCountries = mysql_fetch_assoc($rsCountries);
  }
?>
    </select>
    <input type="submit" name="button" id="button" value="go" />
  </form>

and the shop information that i want to appear below is

 <p><?php echo $row_rsStockists['stockistName']; ?><br />
    <?php echo $row_rsStockists['stockistAdd1']; ?><br />
    <?php echo $row_rsStockists['stockistTown']; ?><br />
    <?php echo $row_rsStockists['stockistCounty']; ?><br />
    <?php echo $row_rsStockists['stockistCountry']; ?><br />
    <?php echo $row_rsStockists['stockistPostCode']; ?><br />
    <?php echo $row_rsStockists['stockistWWW']; ?></p>

thanks for you help in advance

Link to comment
Share on other sites

  • Solution
When the country is selected i want the shop information to show below then menu.

 

 

then you will probably want to design your program LOGIC to do that, one step at a time -

 

1) display your country select/option menu. since you are trying to tell your page what output to get/produce as a result of the request for the page, you should use method='get' in your form. this will cause your country id selection to be passed in the URL so that it persists between page requests.

 

2) when the $_GET country id selection is present on any page request, you would run the code needed to use that selection to query for and display the information that matches that country.

Link to comment
Share on other sites

then you will probably want to design your program LOGIC to do that, one step at a time -

 

1) display your country select/option menu. since you are trying to tell your page what output to get/produce as a result of the request for the page, you should use method='get' in your form. this will cause your country id selection to be passed in the URL so that it persists between page requests.

 

2) when the $_GET country id selection is present on any page request, you would run the code needed to use that selection to query for and display the information that matches that country.

 

hello thanks for the help

 

i have tried the following now

  <form id="form1" name="form1" method="GET" action="">
    <label for="select"></label>
    <select name="select" id="select">
      <?php
do {  
?>
      <option value="<?php echo $row_rsCountries['stockistLocID']?>"><?php echo $row_rsCountries['stockistLocName']?></option>
      <?php
} while ($row_rsCountries = mysql_fetch_assoc($rsCountries));
  $rows = mysql_num_rows($rsCountries);
  if($rows > 0) {
      mysql_data_seek($rsCountries, 0);
	  $row_rsCountries = mysql_fetch_assoc($rsCountries);
  }
?>
    </select>
    <input type="submit" name="button" id="button" value="go" />
  </form>

and the query i have done is

$var1_rsStockists = "-1";
if (isset($_GET['recordID'])) {
  $var1_rsStockists = $_GET['recordID'];
}
mysql_select_db($database_beau, $beau);
$query_rsStockists = sprintf("SELECT * FROM beauAW13_stockist, beauAW13_stockistLoc WHERE beauAW13_stockist.stockistLocID = beauAW13_stockistLoc.stockistLocID  AND beauAW13_stockistLoc.stockistLocID = %s", GetSQLValueString($var1_rsStockists, "int"));
$rsStockists = mysql_query($query_rsStockists, $beau) or die(mysql_error());
$row_rsStockists = mysql_fetch_assoc($rsStockists);
$totalRows_rsStockists = mysql_num_rows($rsStockists);

mysql_select_db($database_beau, $beau);
$query_rsCountries = "SELECT * FROM beauAW13_stockistLoc";
$rsCountries = mysql_query($query_rsCountries, $beau) or die(mysql_error());
$row_rsCountries = mysql_fetch_assoc($rsCountries);
$totalRows_rsCountries = mysql_num_rows($rsCountries);

but when the form is submitted no information is returned

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.