473,406 Members | 2,439 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Read 2 columns from mysql and Populate a html combobox

Hi guys, I have read data from 2 columns in the mysql table. I want to concatenate the data and bind them to the html combo box on the form. From the code below, the read data is okay, the concatenation is okay but the binding is is rather printing the result on the page instead of populating the select option box. Please kindly help me here.

Thank you!
Expand|Select|Wrap|Line Numbers
  1. <!-- Assuming there is a connection to the database -->
  2.    <form name="form1" action="confirm_province.php" method="post" style="margin-left:15px; margin-right:20px;">
  3.         <p><b style="color:#990000;">Select / Choose your Region Number:</b>
  4. <!-- this code here works fine when you read data from only one column. It populates the select box too -->
  5.  
  6. <?php echo "<Select name='region_number' size='1' class='passwordEntry'> ";
  7. $load_region = mysql_query("SELECT region_number FROM region ORDER BY region_number", $con);
  8.  
  9. while ($row = mysql_fetch_array($load_region)) {
  10.   echo '<option value="'. $row['region_number'] .'">' . $row['region_number'].'</option>'; 
  11. echo "</select>";
  12. ?>
  13.  
Expand|Select|Wrap|Line Numbers
  1. <!-- this code here does not work well... It reads the data but does not populate. 
  2. Here, I want to read 2 columns, concatenate and populate the select box. -->
  3.  
  4. <?php echo "<Select name='province_number' size='1'> ";
  5. $load_province = mysql_query("SELECT province_number, province_location FROM province ORDER BY province_number");
  6.  
  7. while ($row = mysql_fetch_array($load_province)) {
  8.  
  9. //$province=$row['province_location']." ".$row['province_number'];
  10.  
  11. echo '<option value="'. $row['province_location'] . $row['province_number'] .'">' . $row['province_location'] .' '.   $row['province_number']. '</option>';
  12.  
  13. echo "</select> ";
  14. }?>
  15.  
  16.  
Apr 8 '13 #1
2 2293
I have solved the problem!
Apr 8 '13 #2
Rabbit
12,516 Expert Mod 8TB
Can you post your solution in case someone else has the same problem?
Apr 8 '13 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Mark | last post by:
I have found many examples of how to access an HTML text field from PHP, but cannot find the reverse - how to load an HTML form from a MySQL database. Specifically, I have an HTML form which...
1
by: anonieko | last post by:
This example applies to javascript, table, cells, rows > > How do you access rows and columns of a HTML table? > > > <script language="javascript"> alert('start');
2
by: portroe | last post by:
in VB. net how do you populate a combobox with items? thanks portroe
0
by: mburghdorf | last post by:
Does anybody know how to populate a combobox in a datagrid with different values per row. Per column isn't a problem but for some reason I can't figure out how to do it per row.
0
by: masterej | last post by:
I'm trying to populate a ComboBox (dropdown style) with strings of text from an ArrayList. The ComboBox is actually being populated with the correct items, however, they appear only as blank...
2
by: rperreta | last post by:
I exported a xml file using .writexml from a dataset and now I would like to populate a combo box from that. Can someone supply a link or sample vb.net code that show's how to do this... much...
5
by: Rich | last post by:
Hello, I have a search application to search data in tables in a database (3 sql server tables). I populate 2 comboboxes with with data from each table. One combobox will contain unique...
4
by: polaris431 | last post by:
All the examples I've seen showing how to populate a combobox using the DataSource property and an ArrayList show the ArrayList object containing objects with at least two properties. I want to...
3
by: salomeh | last post by:
How can i link my database in Mysql to HTML, so that the data in the database shows up in HTML in a table?
3
by: Bob Bedford | last post by:
Hi all, wondering if does exists a mysql to html table function or class written in PHP. something like. createtable($query,fieldname1,fieldname2,fieldname3,); the last parameter would...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.