KateS Posted August 2, 2006 Share Posted August 2, 2006 Can anyone help to save me from an untimely and possibly violent demise and point my owner to where she can find out how to use a select menu in Dreamweaver, which when the user has selected an option will display results from a mysql database in a separate table on the same page? She has tried numerous different ways of doing this and although parts of the script have worked it has not worked fully. She has followed the help menu in dreamweaver, various books on php and mysql and before she ends up throwing me out of the window can someone help me? Please, I'll love you forever, Kate's Mac! Quote Link to comment Share on other sites More sharing options...
legohead6 Posted August 2, 2006 Share Posted August 2, 2006 like display automaticly or after the user clicks submit? (like a search box) Quote Link to comment Share on other sites More sharing options...
KateS Posted August 2, 2006 Author Share Posted August 2, 2006 I would prefer it to use the displayed option and update itself rather than have the user click a submit button but at this stage anything would be useful as i have been unable to get either to work. Quote Link to comment Share on other sites More sharing options...
ryanlwh Posted August 2, 2006 Share Posted August 2, 2006 put onChange="document.myform.submit()" in the dropdown listit would also be helpful if you can show us some of your code. Quote Link to comment Share on other sites More sharing options...
legohead6 Posted August 2, 2006 Share Posted August 2, 2006 and then to find what they want displayed use a switch command...then queary the database and display the results Quote Link to comment Share on other sites More sharing options...
KateS Posted August 2, 2006 Author Share Posted August 2, 2006 Have tried using onChange="document.forms['Businesses'].submit()" but that didn't work. I have tried using a variable to store the information from the selected option but it doesn't recognise it. Also as I have been working on this now for quite some time there is the chance that I have screwed something up as I have changed something else as I am getting a mysql syntax error message for a line which has only a <tr> tag on it. Quote Link to comment Share on other sites More sharing options...
KateS Posted August 2, 2006 Author Share Posted August 2, 2006 This is the code that I tried last but I have tried various different ways. SearchString was the name that I had for the variable for the menu result.<?php $SearchString_DriffieldRS = "-1";if (isset($_GET['SearchString'])) { $SearchString_DriffieldRS = (get_magic_quotes_gpc()) ? $_GET['SearchString'] : addslashes($_GET['SearchString']);}mysql_select_db($database_myTownQuery, $myTownQuery);$query_DriffieldRS = "SELECT * FROM Businesses WHERE Businesses.town='Driffield' and Businesses.business_type='".chop($_GET['SearchString'])."'' ORDER BY Businesses.business_name";$DriffieldRS = mysql_query($query_DriffieldRS, $myTownQuery) or die(mysql_error());$row_DriffieldRS = mysql_fetch_assoc($DriffieldRS);$totalRows_DriffieldRS = mysql_num_rows($DriffieldRS);?> <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="get" name="Businesses"> <select name="SearchString" title="<?php echo chop($_GET['SearchString']); ?>" onChange="document.forms['Businesses'].submit()">Â <option selected>Please select</option> <option value="Accountants">Accountants</option> <option value="Acupuncture">Acupuncture</option> <option value="Advertising Services">Advertising Services</option> <option value="Agricultural Services">Agricultural Services</option> </select> </form> <?php if ($totalRows_DriffieldRS > 0) { // Show if recordset not empty ?> <?php echo chop($_GET['SearchString']); ?><br> <?php do { ?> <?php echo $row_DriffieldRS['business_type']; ?><br> <?php echo $row_DriffieldRS['business_name']; ?> <?php echo $row_DriffieldRS['first_name']; ?> <?php echo $row_DriffieldRS['last_name']; ?> <?php echo $row_DriffieldRS['address1']; ?> <?php echo $row_DriffieldRS['address2']; ?> <?php echo $row_DriffieldRS['town']; ?> <?php echo $row_DriffieldRS['county']; ?> <?php echo $row_DriffieldRS['postcode']; ?><br> <?php echo $row_DriffieldRS['tel_no_01']; ?> <?php echo $row_DriffieldRS['tel_no_02']; ?><br> <br> <?php } while ($row_DriffieldRS = mysql_fetch_assoc($DriffieldRS)); ?> <?php } // Show if recordset not empty ?> <?phpmysql_free_result($DriffieldRS);?> Quote Link to comment Share on other sites More sharing options...
legohead6 Posted August 2, 2006 Share Posted August 2, 2006 k heres a simple way to do it if the user clicks submit menu name is menu and sbmit name is submit! I think this would also work into the onchange but im not 100% sure how to configure it![code]if(isset($_POST['submit'])){$menu=$_POST['menu'];switch($menu){case "Pizza"://run query herebreak;case "cookies":///blah blahbreak;//so on and so fourth the word in the quotes is the value of the option in the menu.....}}[/code] Quote Link to comment 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.