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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.