Page 1 of 1

database generated Form Processing

Posted: Sat May 19, 2007 6:01 am
by ch_Faisal81
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi Guys,

 I have to develope a web based database application, in which i have some form
 generated by data coming from tables, and user can select any of given options.

 in form i will show only list of items lets say course but not there ID,
 i know i can dereference the value using _POST['course'] course here <select name=course>

 here starts my question , how can i detect the ID/name of selected option.[s]bcoz[/s] [size=150][color=green]because[/color][/size] to manipulate
 the data further i need to know which ID was selected,not the value.

  

piece of sample code.
[syntax="html"] <select name='course'>
 <option name=$ID>$coursename</option>
 <option name=$ID>$coursename</option>
 <option name=$ID>$coursename</option>
 </select>
With $_POST['course']; i get coursename selected , how to konw related ID ?[/syntax]

Code: Select all

function dropdown($identifier,$pairs,$firstentry)
{
// dropdown list with the <select> element and title
$dropdown = "<select name="$identifier" >";
$dropdown .= "<option name="">$firstentry</option>";
// Create the dropdown elements
foreach($pairs AS $value => $name)
{
$dropdown .= "<option name="$value">$name</option>";
}
// Conclude the dropdown and return it
echo "</select>";
return $dropdown;
}

any help would be appreciated, regards.


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

[quote="[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1"][b]11.[/b] Please use proper, complete spelling when posting in the forums. AOL Speak, leet speak and other abbreviated wording can confuse those that are trying to help you (or those that you are trying to help). Please keep in mind that there are many people from many countries that use our forums to read, post and learn. They do not always speak English as well as some of us, nor do they know these aberrant abbreviations. Therefore, use as few abbreviations as possible, especially when using such simple words.

Some examples of what not to do are ne1, any1 (anyone); u (you); ur (your or you're); 2 (to too); prolly (probably); afaik (as far as I know); etc.[/quote]

Posted: Sat May 19, 2007 8:28 am
by aaronhall
Everything looks good, except the option element should have the attribute "value", not "name", as demonstrated here