Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Wednesday, November 11, 2026
About Us
Magazine
Open Source
CVS
Services
Index  »  Projects  »  phpMyEdit  »  Forum  »  Join tables to populate dropdown menu

phpMyEdit General     Join tables to populate dropdown menu
Post new topic   Reply to topic    
 
sbatty     Joined: 04 Dec 2006   Posts: 2  
Post Posted: 2006-12-04 20:24
Back to top  Reply with quote     

I've been reading the docs and forums for hours now and apparently I'm an idiot. I still haven't the slightest clue how to populate the options in a select menu from a database column. Here's the table I'm trying to use to populate the dropdown list:
Code:

CREATE TABLE `counties` (
  `fips_code` char(3) NOT NULL default '',
  `name` varchar(11) NOT NULL default '',
  PRIMARY KEY  (`fips_code`),
  KEY `name` (`name`)
) TYPE=MyISAM COMMENT='FIPS County Codes and County Names';

The main table has a 'fips_code' column which maps to the primary key column 'fips_code' in the counties table. There are 102 rows in the counties table so I don't want to have to declare them all in the code. I currently do this with hand-coded php like so:
Code:

<?php   do {  ?>
        <option value="<?php echo $row_counties['fips_code']?>"><?php echo $row_counties['name']?></option>
        <?php }
               while ($row_counties = mysql_fetch_assoc($counties));
                 $rows = mysql_num_rows($counties);
                 if($rows > 0) {
                   mysql_data_seek($counties, 0);
                    $row_counties = mysql_fetch_assoc($counties);
                 }   ?>

Can someone try to explain how this is done? All examples I've found show the select options being coded in the 'description' element of the values array.

Thanks

I forgot to point out that I want the value of the select option to be fips_code while the displayed text is the county name.

 
sbatty     Joined: 04 Dec 2006   Posts: 2  
Post Posted: 2006-12-04 20:48
Back to top  Reply with quote     

Nevermind. I told you I was an idiot. I got the syntax figured out and solved the mysql error. It works fine now. Has anyone figured out why table names with a hyphen (-) in them cause PME to throw an error?

 
Post new topic   Reply to topic    

Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top · Feedback form · Application form
Report bug on PLATON.SK website · Terms of use · Privacy policy