jonnyfortis Posted August 6, 2013 Share Posted August 6, 2013 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 Quote Link to comment https://forums.phpfreaks.com/topic/280890-select-menu-to-show-record-selected-on-same-page/ Share on other sites More sharing options...
Solution mac_gyver Posted August 7, 2013 Solution Share Posted August 7, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/280890-select-menu-to-show-record-selected-on-same-page/#findComment-1443814 Share on other sites More sharing options...
jonnyfortis Posted August 9, 2013 Author Share Posted August 9, 2013 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 Quote Link to comment https://forums.phpfreaks.com/topic/280890-select-menu-to-show-record-selected-on-same-page/#findComment-1444115 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.