简体   繁体   中英

how to display data in a Combobox from MySql database table and other fields in textbox - php

I am using phpMyAdmin localhost.
I have a table
Table1: fields are

BatchName, BatchID, Cource, Stream,StreamCode
values: 
HS1A-2019   1   HS  Arts    1
HS1C-2019   2   HS  Commerce    3
HS1SC-2019  3   HS  Science     2

Now first I want to display BatchName in a Combobox. secondly, I want while selecting a BatchName from the Combobox it should display respective Course, Stream, StreamCode in textboxes. Thank you in advance.

Assuming you already got an array of objects from the SQL query, you can then put the BatchNames into the options of a select element.
All the other information you put into textboxes and hide them using CSS.

Last but not least you write an onchange handler for your select element that will unhide the textboxes.

That's the rough overview of how to tackle this problem, as I assumed you wanted help with the general concept of how to display stuff depending on the selection of your select box using PHP. (That's not possible in PHP and HTML only, you need JS as well)

If your problem was with one of the implementations, please provide an example of what you got so far and where you ran into problems.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM