Sanfoor Posted June 10, 2010 Share Posted June 10, 2010 Hi there friends! I'm having a problem with my code to show persons by their job title I made a code with a dropdown menu that get the job title info from the database, and i wanted to get the persons info when i choose the job title from the dropdown menu BUT it's not working, can any one help me and see what i did wrong this is what i wrote Best Regards to you all ================================== <?php // Connect To MySQL mysql_connect("localhost", "username", "password") or die(mysql_error()); mysql_select_db("database") or die(mysql_error()); //$JobTitleSlkt="SELECT JobTitle FROM table order by JobTitle ASC"; ?> <SELECT> <? $query=("select * from table order by JobTitle, JobTitle desc"); $result=mysql_query($query) or die ("Unable to Make the Query:" . mysql_error() ); while($row=mysql_fetch_array($result)){ echo "<OPTION VALUE=".$row['JobTitle'].">".$row['JobTitle']."</OPTION>"; $query = sprintf("SELECT * FROM table WHERE JobTitle='%s' order by FNamn ASC", mysql_real_escape_string($row['JobTitle'])) or die ("Unable to Make the Query:" . mysql_error() ); } ?> </SELECT> <? // Perform Query $result2 = mysql_query($query); echo "<table border='1' align='center'>"; echo "<tr> <th>Fornamn</th> <th>Efternamn</th> <th>PersonNummer</th> <th>Stad</th> <th>Address</th> <th>PostNr</th> <th>PostAd</th> <th>Mobil</th> <th>JobTitle</th> <th>Motte</th> </tr>"; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result2 )) { // Print out the contents of each row into a table echo "<tr><td>"; echo $row['FName']; echo "</td><td>"; echo $row['LName']; echo "</td><td>"; echo $row['PersonNmr']; echo "</td><td>"; echo $row['Stad']; echo "</td><td>"; echo $row['Address']; echo "</td><td>"; echo $row['PostNr']; echo "</td><td>"; echo $row['PostAd']; echo "</td><td>"; echo $row['Mobil']; echo "</td><td>"; echo $row['JobTitle']; echo "</td><td>"; echo $row['Motte']; echo "</td></tr>"; } echo "</table>"; ?> Link to comment https://forums.phpfreaks.com/topic/204382-dropdown-menu-problem/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.