Okay so I have created a function which brings up a column of information into a html drop down menu from a certain table. Now I want the data selected to be put into a value so it can be used in an upload form. This is the function. Thanks to LastMitch.

function namealbums()
{
$conn = mysql_connect("localhost", "root", "") or die ("could not connect to mysql");
mysql_select_db("photos") or die ("no database");
$query = "SELECT pic_id, album FROM albumname ORDER BY album";
$result = mysql_query ($query);
echo "<select name=dropdown value=''>Dropdown</option>";
while($r = mysql_fetch_array($result)){
echo "<option value=$r[pic_id]>$r[album]</option>";
}
echo "</select>";

}
?>

Now lets say someone selects an option from the drop down menu. I want that selection to have an id to be used in upload form. Here is the Html

<table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<form action="upload_file.php" method="post" enctype="multipart/form-data">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<label for="file" >Filename:</label>
</tr>
<tr>
<td width="78"></td>
<td width="6"></td>
<td width="294"><input id="infile" name="infile[]" type="file" onBlur="submit();" multiple></td>
</tr>
<tr>
</tr>
</table>
</td>
</table>
<table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td width="78"></td>
<td width="6"></td>
<td width="294">
Select Album
</td>
<table width="300px" align="center" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td cellpadding="100">

<?php echo namealbums();?>

</td>
</tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><input type="submit" name="Submit" value="Upload"></td>
</form>
</table>
</table>

This form also uploads pictures which have been selected by the user.

in your select input, have an onchange function that will call a function that will reload the page (or direct to another) with the value in the url.

<select name="cars" onchange="myfunction()">

then call for the redirect function.

function myfunction(){
  var sel = document.getElementById("cars").value;
  window.location = "yourpage.php?id="+sel;
}

Then use the $_GET to get the value from the url. This is just to get the ball rolling. Hope it helps

I tried putting this funtion into my page but it says there is a parse error lines 2 and 3 have something wrong with them. I have changed the fields cars and yourpage.php?id to my url and name but its still says parse error.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.