be carefull with the results of mysql_fetch_array, array names are DB
field names, for easier access =)

<?php
    //connecting to the database
    $link = mysql_connect("localhost","lodestone","trypass");
    if(!$link)
      Print "No connection to the database";

    if (!mysql_select_db("catapult_com")){
      Print "Couldn't connect database";

    $sql="SELECT OrgName From TableResults ORDER BY OrgName";

    //get result or show what happened
    $result=mysql_query($sql)or die(mysql_error());

    //start the select
    $content = "<select name=\"organization\">";

    while($orgData=mysql_fetch_array($result))
    {
      // note that OrgName is the field name in the database.
      // for value you may use the org_id instead, if you have one in the
DB
      $content .= "<option
value=\"".$orgData['OrgName']."\">".$orgData['OrgName']."</option>\n");
    }

    $content .="</select>\n";

    echo $content;

?>
hope it helps :-)

------------------------------------------------------------------
"Few are those who see with their own eyes and feel with their own
hearts."
Albert Einstein
-----------------------------------------------------------------
Maciek Ruckaber Bielecki



On Sun, 29 Dec 2002, 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
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to