drranch Posted August 3, 2006 Share Posted August 3, 2006 I've had great luck here before so here goes.....another dilemmaI’m so glad you people love doin' this stuff!I have a dynamic select list that is pulling data from my database, but it’s not able to retrieve results when selecting an item from the dynamic list.PHP Code: <?phpmysql_select_db($database_fred, $fred);$query_cars = "SELECT * FROM cars WHERE username='{$_SESSION[loginUsername]}' ORDER BY car.name";$cars = mysql_query($query_cars, $fred) or die(mysql_error());$row_cars = mysql_fetch_assoc($cars);$totalRows_cars = mysql_num_rows($cars);?>Form: <form name="cars" action="" method="POST" ><blockquote><p></p><p><SELECT name="carlist" size="1" onChange="Javascript:document.cars.submit();"><?phpdo {?><option value="<?php echo $row_cars['name']?>"><?php echo $row_cars['name']?></option><?php} while ($row_cars = mysql_fetch_assoc($cars));$rows = mysql_num_rows($cars);if($rows > 0) {mysql_data_seek($cars, 0);$row_cars = mysql_fetch_assoc($cars);}?>Do I need another script to retrieve results based on the value selected by the end user? Right now how it stands is when I select an item from the list my screen does nothing. I do have the connection set at the top of the PHP file – Thought I would save a lot of unnecessary reading. Connection works find because I have options to select from. *sigh* Quote Link to comment Share on other sites More sharing options...
CTM Posted August 3, 2006 Share Posted August 3, 2006 PHP can't do dynamic things :)What you should do is fetch all the possible results before outputting anything and add them in a Javascript array. Then, through Javascript means, you can switch options dynamically. Forget PHP and Dynamic, unless you're using AJAX. Quote Link to comment Share on other sites More sharing options...
king arthur Posted August 3, 2006 Share Posted August 3, 2006 You have not set an action for the form to use when it is submitted. You will need a script to process the result of the selection, and put the name of this script in the action parameter of the opening form tag. The script would access the value of the selection in the variable $_POST["carlist"]. Quote Link to comment Share on other sites More sharing options...
drranch Posted August 3, 2006 Author Share Posted August 3, 2006 ;DThanks to the KING!That's what I thought, but I guess I just needed someone to hold my hand as I learn........One step forward again. And again I have good luck here!thank you, thank you, thank you 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.