Thanks Maciek.
With the code that you gave me, I am getting the error :
Parse error: parse error in
/usr/local/www/virtual2/66/184/35/184/html/findresults.php on line 114.
My lines are as follows :
$content.= "<option
value=\"".$orgData['OrgName']."\">".$orgData['OrgName']."</option>\n");
Can u help me a little bit more?
Thanks
denis
----- Original Message -----
From: "Maciek Ruckgaber Bielecki" <[EMAIL PROTECTED]>
To: "Denis L. Menezes" <[EMAIL PROTECTED]>
Cc: "Justin French" <[EMAIL PROTECTED]>; "PHP general list"
<[EMAIL PROTECTED]>
Sent: Sunday, December 29, 2002 1:41 AM
Subject: Re: [PHP] Populating a list box from a database - The code
>
> 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