virtuexru Posted May 22, 2006 Share Posted May 22, 2006 Need some help here, how do I get whatever you choose in the dropdown to output into the PHP.[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<body><form action="insert.php" method="post"> <table width="500" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td>Job Title:</td> <td><input type="text" name="title"></td> </tr> <tr> <td>Job Number:</td> <td><input type="text" name="number"></td> </tr> <tr> <td>Company Description:</td> <td><input type="text" name="description"></td> </tr> <tr> <td>Category:</td> [b] <td><select name="category" onChange="MM_jumpMenu('parent',this,0)"> <option>Infastructure</option> <option>Development</option> <option>BA/PM</option> </select> </td>[/b] </tr> <tr> <td>Salary:</td> <td><input type="text" name="salary"></td> </tr> <tr> <td>Additional Compensation Information:</td> <td><input type="text" name="addcomp"></td> </tr> <tr> <td>Position Type:</td> <td><input type="text" name="position"></td> </tr> <tr> <td>Location:</td> <td><input type="text" name="location"></td> </tr> <tr> <td>Job Details:</td> <td><input type="text" name="details"></td> </tr> </table> <div align="center"> <input type="Submit"> </div></form><div align="center">To see output of database, click <a href="output.php">Here</a></div></body>[/quote]into the output which is here:[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<?$user="****";$password="****";$database="****";mysql_connect(localhost,$user,$password);@mysql_select_db($database) or die( "Unable to select database");$query="SELECT * FROM joborder";$result=mysql_query($query);$num=mysql_numrows($result);mysql_close();echo "<b><center>Database Output</center></b><br><br>";?><table border="0" cellspacing="2" cellpadding="2"><tr><th><font face="Arial, Helvetica, sans-serif">Job Title:</font></th><th><font face="Arial, Helvetica, sans-serif">Job Number:</font></th><th><font face="Arial, Helvetica, sans-serif">Company Description:</font></th><th><font face="Arial, Helvetica, sans-serif">Category:</font></th><th><font face="Arial, Helvetica, sans-serif">Salary:</font></th><th><font face="Arial, Helvetica, sans-serif">Additional Compensation Information:</font></th><th><font face="Arial, Helvetica, sans-serif">Position Type:</font></th><th><font face="Arial, Helvetica, sans-serif">Location:</font></th><th><font face="Arial, Helvetica, sans-serif">Job Details:</font></th></tr><?$i=0;while ($i < $num) {$title=mysql_result($result,$i,"title");$number=mysql_result($result,$i,"number");$description=mysql_result($result,$i,"description");$category=mysql_result($result,$i,"category");$salary=mysql_result($result,$i,"salary");$addcomp=mysql_result($result,$i,"addcomp");$position=mysql_result($result,$i,"position");$location=mysql_result($result,$i,"location");$details=mysql_result($result,$i,"details");?><tr><td><font face="Arial, Helvetica, sans-serif"><? echo $title; ?></font></td><td><font face="Arial, Helvetica, sans-serif"><? echo $number; ?></font></td><td><font face="Arial, Helvetica, sans-serif"><? echo $description; ?></font></td><td><font face="Arial, Helvetica, sans-serif"><? echo $category; ?></font></td><td><font face="Arial, Helvetica, sans-serif"><? echo $salary; ?></font></td><td><font face="Arial, Helvetica, sans-serif"><? echo $addcomp; ?></font></td><td><font face="Arial, Helvetica, sans-serif"><? echo $position; ?></font></td><td><font face="Arial, Helvetica, sans-serif"><? echo $location; ?></font></td><td><font face="Arial, Helvetica, sans-serif"><? echo $details; ?></font></td></tr><?$i++;}echo "</table>";[/quote] Quote Link to comment https://forums.phpfreaks.com/topic/10211-using-dropdown-menus-in-phpmysql-form/ Share on other sites More sharing options...
michaellunsford Posted May 22, 2006 Share Posted May 22, 2006 what's the jumpmenu for? Quote Link to comment https://forums.phpfreaks.com/topic/10211-using-dropdown-menus-in-phpmysql-form/#findComment-38047 Share on other sites More sharing options...
virtuexru Posted May 22, 2006 Author Share Posted May 22, 2006 It allows the user to only select 3 options for that certain field. I then what whatever they select to go into the database under the [b]category[/b] field. Quote Link to comment https://forums.phpfreaks.com/topic/10211-using-dropdown-menus-in-phpmysql-form/#findComment-38050 Share on other sites More sharing options...
michaellunsford Posted May 22, 2006 Share Posted May 22, 2006 the jumpmenu will submit the form (or run that dreamweaver javascript) when that option is changed -- probably not what you're looking for. I'd remove the onclick="MM_" thing. Other than that, your select code looks accurate.On the other end, the variable $_POST['category'] will have the value they selected -- just like the $_POST['title'] will be whatever they typed in the title textfield.so [code]$query="SELECT * FROM `joborder` WHERE `category` = '".$_POST['category']."'";[/code] will query the database for all records where your category field is what they selected.Is that what you're trying to do? Quote Link to comment https://forums.phpfreaks.com/topic/10211-using-dropdown-menus-in-phpmysql-form/#findComment-38053 Share on other sites More sharing options...
virtuexru Posted May 22, 2006 Author Share Posted May 22, 2006 Ah, yea amazing. I took out the MM_ stuff and it worked great.Thanks a lot. Quote Link to comment https://forums.phpfreaks.com/topic/10211-using-dropdown-menus-in-phpmysql-form/#findComment-38059 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.