drop down list

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jfilan
Forum Newbie
Posts: 3
Joined: Sat Oct 21, 2006 6:07 pm

drop down list

Post 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
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

Code: Select all

echo "<option>" . $row['name'] . "</option>";
:wink:
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Post Reply