Question
Get the Selected from List (Drop Down List) and Find the associated Primary Key from Database
Hi,
I'm doing a web application with mysql as my database.
I have a List with dynamic values from my database. (The values can appear)
The values are names of people.. E.g. Amy, Ali, Bobby....
This is a insert function i'm doing...
When the user selects a name from the list. E.g. Amy
I need to know the ID of this person.
That is, my database contains a table 'Adult' and the columns are ID (primary key), name (amy, ali...) , etc..
Because this insert function i'm doing is on another table name 'Child' .. In this 'Child' table, there's a foreign key of the ID in Adult table. thus when inserting a new row for the child, i need to insert the associated adult which is the ID.
Hope you understand what i'm saying..
Anyway i use Visual Basic before and using the codes of VB... what i thinking was it seems like. ... (this is just a rough coding as i already forget the accurate codings)
ListBox1.Selected = varName
select ID from Adult where name = 'varName'
then i have to store the result i got into a hidden field so as to perform the insert command with the resulted id...
Thanks.
I'm doing a web application with mysql as my database.
I have a List with dynamic values from my database. (The values can appear)
The values are names of people.. E.g. Amy, Ali, Bobby....
This is a insert function i'm doing...
When the user selects a name from the list. E.g. Amy
I need to know the ID of this person.
That is, my database contains a table 'Adult' and the columns are ID (primary key), name (amy, ali...) , etc..
Because this insert function i'm doing is on another table name 'Child' .. In this 'Child' table, there's a foreign key of the ID in Adult table. thus when inserting a new row for the child, i need to insert the associated adult which is the ID.
Hope you understand what i'm saying..
Anyway i use Visual Basic before and using the codes of VB... what i thinking was it seems like. ... (this is just a rough coding as i already forget the accurate codings)
ListBox1.Selected = varName
select ID from Adult where name = 'varName'
then i have to store the result i got into a hidden field so as to perform the insert command with the resulted id...
Thanks.
