Jump to content

PHP/SQL dropbox


lostjoe

Recommended Posts

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);

 

?>
Link to comment
https://forums.phpfreaks.com/topic/276946-phpsql-dropbox/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.