Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

javascript and php/mysql

Status
Not open for further replies.

shosuro

Technical User
Feb 21, 2004
2
PL
i have something like this:

group=new Array()
group[1][1]=new Option("Bronze","47");
group[1][2]=new Option("Silver","46");
group[1][3]=new Option("Gold","45");

is it possible to fill the options dynamically with data from mysql db? fe. let's assume the colors would have to be pulled from colors table from mysql db by some select statement.

i'd be grateful for any help.
 
sure.
Code:
echo &quot;<script language=javascript&quot;>
      group=new Array()&quot;;

$x=1;//counter
$y=1;//another counter

while ($rows=mysql_fetch_array($result)){
 
    $color=$rows['color'];
    $someValue=$rows['SomeFieldValue'];
      
    echo &quot;group[$y][$x]=new Option(&quot;$color&quot;,&quot;$someValue&quot;);

    $x++;
}

Bastien

Any one have a techie job in Toronto, I need to work...being laid off sucks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top