News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Help: php + java combo

Started by Makavelli, September 20, 2004, 10:43:23 AM

Previous topic - Next topic

Makavelli

Please help!! I'm trying to generate a list that will look something like this


group[1][0] = new Option("Alpine","101");
group[1][1] = new Option("Anthony","102");
group[1][2] = new Option("Balmorhea","103");



but everytime I run the code below, it populates it with this format. What am I doing wrong? Please help


group[1][0] = new Option("Alpine
","101");
group[1][1] = new Option("Anthony
","102");
group[1][2] = new Option("Balmorhea
","103");




<?php
mysql_select_db
($database_cnDefault$cnDefault);
$query_rsRegion "SELECT * FROM regions";
$rsRegion mysql_query($query_rsRegion$cnDefault) or die(mysql_error());
$row_rsRegion mysql_fetch_assoc($rsRegion);
$totalRows_rsRegion mysql_num_rows($rsRegion);
?>


<script language="JavaScript">
<!--

<?php
$txtListRelation 
"rgId";
$txtListLabel "cityName";
$txtListValue "cityId";
$ListRS $rsCities;
$ListRow $row_rsCities;

$varCheckGroup $ListRow[$txtListRelation];
$varCheckLength 0;
$varMaxLength 0;
do {
if (
$ListRow[$txtListRelation] != $varCheckLast ){
$varCheckLength 0;
}
?>

group[<?php echo $ListRow[$txtListRelation?>][<?php echo $varCheckLength ?>] = <?php echo "new Option(\"".$ListRow[$txtListLabel]."\",\"".$ListRow[$txtListValue]."\");\n" ?>
<?php
$varCheckLast 
$ListRow[$txtListRelation];
$varCheckLength++;
} while (
$ListRow mysql_fetch_assoc($ListRS));
?>


//-->
  </script>
If you fall stand tall and come back for more- Pac

Parham

$txtListLabel has newlines added in the database, you might want to remove the newline before you use it in the echo statement.

[Unknown]

Probably..

<?php echo "new Option("".$ListRow[$txtListLabel]."\",\"".$ListRow[$txtListValue]."\");\n" ?>

<?php echo 'new Option(", trim($ListRow[$txtListLabel]), '","', $ListRow[$txtListValue], "\");\n"; ?>

-[Unknown]

Advertisement: