Click here to Skip to main content
15,905,508 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello..
I have a list in my form.. When i select ID "01" from the list i want the name, address ... from the same table in my database to appear in the text box on my form so that i can update the values..
Help me..
Thank you...
Posted
Comments
OPees 12-Mar-14 8:34am    
Question not clear can you put you code..!!
Member 10626057 12-Mar-14 8:41am    
<tr><td>Lecturer ID:</td>
";
while ($row=mysql_fetch_array($result)) {
echo "<option>".$row["lecturer_id"]."</option>";
echo $row["lecturer_lastname"] ;
}
echo "</select>"
?><br/>


It is displaying only the ID.. I want to display the name as well.. When i select 1 ID i want to get its corresponding name..

1 solution

You see an the id because it is in the typical location to display an HTML value: between the tags. You need something like this:

PHP
ECHO "<option value='" . $row['lecturer_id'] . "'>" .  $row['lecturer_lastname']. "</option>";

This will display the name as the option and return the id as the value of the option. If the value is that in your database table, you can easily pull the requested data.

Update: fixed incorrect quotes.
 
Share this answer
 
v4
Comments
Member 10626057 12-Mar-14 9:13am    
its not working..
getting Parse error: syntax error, unexpected '"', expecting ',' or ';'
W Balboos, GHB 12-Mar-14 10:36am    
I fixed some strange changes that occurred to the quotations (" became '). You really should have considered the error message and looked for the problem which it described exactly ("")
Member 10626057 12-Mar-14 10:42am    
i guess there is a problem with the editor --'
Member 10626057 12-Mar-14 11:25am    
your code is displaying only the lastname in the list.. not even the iD
W Balboos, GHB 12-Mar-14 11:30am    
My code is displaying only the last name because that is the reference in your code sample. If you want more, adjust the code. The ID is not display, but is internal to the <select> control.

You apparently are in need of some study not only of php, but of HTML. After your studies you will better understand what I suggested and be able to adapt it to your needs.

Personally, I try to master (or at least become well versed) in one technology at a time so as not to become hopelessly befuddled.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900