Page 1 of 1

drop down list

Posted: Sat Oct 21, 2006 6:21 pm
by jfilan
I have a table called "upload" with a few columns that are being populated by an upload script. I would like to be able to return data in the column name "name" onto the screen within a drop down. When the "name" is selected from the dropdown you are redirected to a "details.php?id=1" page that displays the contents of that row in the database. IT SOUNDS SO EASY but I am having trouble getting data into the select and getting that to navigate to a different page with actual details on it. I have something like this:

Code: Select all

<?php
	echo "<select name=\"name\">"; 
	echo "<option size =30 selected>Select</option>";
	if(mysql_num_rows($sql_result)) 
	{ 
	while($row = mysql_fetch_assoc($sql_result)) 
	{ 
	echo "<option>$row[name]</option>"; 
	} 

	} 
	else {
	echo "<option>No Names Present</option>";  
	} 
	?>
I just want to be able to select something from the drop down (i.e. data from a specific column, in this case "name") and when it's selected it will send the user to a page w/ the data for that row on the page.

Any help is much appreciated.

Thanks,

JOsh

Posted: Sat Oct 21, 2006 6:24 pm
by s.dot

Code: Select all

echo "<option>" . $row['name'] . "</option>";
:wink: