Re: Populating a list box from a database - The code
| From: | John Nichel | Date: | Sat, 28 Dec 2002 18:04:31 +0000 |
| Subject: | Re: Populating a list box from a database - The code | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-129515@lists.php.net to get a copy of this message | ||
Closing parenthesis...remove it.
Denis L. Menezes wrote:
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" <maciek@geekbunker.hn.org> To: "Denis L. Menezes" <menezesd@singnet.com.sg> Cc: "Justin French" <justin@indent.com.au>; "PHP general list" <php-general@lists.php.net> Sent: Sunday, December 29, 2002 1:41 AM Subject: Re: [PHP] Populating a list box from a database - The code-- By-Tor.com It's all about the Rush http://www.by-tor.combe 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 theDB$content .= "<optionvalue=\"".$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