I assume you want the array populated with something other than the display name in the <select>, so I've made up "OrgId" as a field name in your database. How 'bout something a little easier to read, using a more consistent style?
<?php if (!$db=mysql_connect("localhost","lodestone","trypass")) $err=mysql_error(); if (!$err) if (!mysql_select_db("catapult_com")) $err=mysql_error(); if (!$err) { $q="SELECT OrgId,OrgName FROM TableResults ORDER BY OrgName"; if ($r=mysql_query($q,$db)) { $options=array(); // for clarity while ($row=mysql_fetch_array($r)) $options[$row["OrgId"]]=$row["OrgName"]; } else $err=mysql_error(); } // If all's well so far, show the <select>... if ($err) print "Database error: <tt><b>" . $err . "</b></tt>"; else { print "<select name='OrgName[]' size=5 id='OrgName'>\n" foreach ($options as $id => $name) printf("\t<option value='%s'>%s\n",$id,$name); print "</select>\n"; } ?> Note that none of this code has been tested. :) p On Sun, Dec 29, 2002 at 01:18:22AM +0800, Denis L. Menezes wrote: > > <select name="OrgName[]" size=5 id="OrgName" > > <?php > //connecting to the database > $link = mysql_connect("localhost","lodestone","trypass"); > if ($link){ > Print ""; > } else { > Print "No connection to the database"; > } > if (!mysql_select_db("catapult_com")){ > Print "Couldn't connect database"; > } else { > Print ""."<br>\n"; > } > > $sql="SELECT OrgName From TableResults ORDER BY OrgName"; > $result=mysql_query($sql); > > While($Organisation=mysql_fetch_array($result)) > { > Print("<OPTION VALUE=\"$Organisation[0]\">$Organisation[1]\n"); > } > > ?> > </select> > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- Paul Chvostek <[EMAIL PROTECTED]> Operations / Abuse / Whatever it.canada, hosting and development http://www.it.ca/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php