[UPHPU] Off topic: mysql + php + javascript dropdown lists
Velda Christensen
velda at novapages.com
Fri May 4 14:43:56 MDT 2007
Ray Hunter wrote:
> in not following what you are trying to do and what database you are
> running the query in.
>
> if you could provide some ddl for the tables that would be great too and
> what you are trying to accomplish.
No worries. I figured it out last night after the brain haze had died
down. Here's what I ended up doing, in case someone needs it. I got a
javascript here: http://www.yxscripts.com/cs/chainedselects.html
I used these queries:
$query_r1 = "SELECT distinct apn1 FROM datalilst ORDER BY apn1";
$query_r2 = "SELECT distinct apn2, apn1 FROM `datalilst` order by apn2";
... and this code to generate the the stuff that script looks for. I
know, there are probably a million more eloquent ways to do it, but what
can I say, coding isn't exactly my bag:
addListGroup("apns", "apn1");
<?php do { ?>
addList("apn1", "<?php echo $row_r1['apn1']; ?>", "<?php echo
$row_r1['apn1']; ?>
", "apn1-<?php echo $row_r1['apn1']; ?>
");
<?php
} while ($row_r1 = mysql_fetch_assoc($r1)); mysql_free_result($r1);
do { ?>
addOption("apn1-<?php echo $row_r2['apn1']; ?>" , "<?php echo
$row_r2['apn2']; ?>" , "<?php echo $row_r2['apn2']; ?>");
<?php
} while ($row_r2 = mysql_fetch_assoc($r2)); mysql_free_result($r2);
?>
Hoping it helps someone :)
-V
More information about the UPHPU
mailing list