lostjoe Posted April 14, 2013 Share Posted April 14, 2013 Im trying to display the songs for an artist i select on a drop down menu but i just cant get it to work, ive been trying for hours but i have got nowhere. This is my dropbox code, it debugs fine and i can click on my artists and submit fine but when the browser moves onto my process3.php it does'nt show the artist with their data (title, artist, genre, year, price) <html> <body> <form action="process3.php" method="post"> <p>View grocery current quantity in stock? <select name="band"> <option value=""> -- Please select band to view-- </option> <?php $con = mysql_connect("localhost","root"); mysql_select_db("cd_online", $con); $query = "SELECT id, artist FROM songs"; $result=mysql_query($query); while ($row=mysql_fetch_array($result)) { echo "<option value =\"{$row['id']}\"> {$row['artist']} </option>\n"; } mysql_close($con); ?> </select> <br/> <input type="submit" name="submit" value="Submit" /> </form> </html> The sample code i've been given is below i'll give you this version as when i change it it doesn't work (it does'nt debug as it is they give it as an outline but im completly lost) <?php $selectedfruit = $_POST['fruit']; print "$selectedfruit"; $con = mysql_connect("localhost","root"); mysql_select_db("grocery_db", $con); $query = "SELECT `curr_qty` FROM grocery_inventory WHERE item_name =\"$selectedfruit\""; print "$query"; $result = mysql_query($query, $con); while($myrow = mysql_fetch_array($result)) {print $myrow["curr_qty"]; } mysql_close($con); ?> Quote Link to comment https://forums.phpfreaks.com/topic/276946-phpsql-dropbox/ Share on other sites More sharing options...
jcbones Posted April 14, 2013 Share Posted April 14, 2013 I will give you a starting point. <?php if($_SERVER['REQUEST_METHOD'] == 'POST') { echo $_POST['band']; } else { echo 'Form not sent!'; } Quote Link to comment https://forums.phpfreaks.com/topic/276946-phpsql-dropbox/#findComment-1424724 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.