RE: [PHP] question on listbox.
Might this be better? print "\n"; print "Select Category"\n //Query $sql="SELECT DISTINCT CategoryName From Categories ORDER BY CategoryName"; $result=mysql_query($sql); if ($result) { While($Category=mysql_fetch_array($result)) { Print"$Category['name']\n"; } mysql_free_result($result[$a]); print "\n"; } Leonard. www.phpna.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] question on listbox.
On Saturday 01 February 2003 20:40, Denis L. Menezes wrote: Please don't top-post. > Looks like I am too dumb. I still cannot do it. can u please help me > further? I could write out the complete code for you -- but then I'll have to charge you for it :-) OTOH I can walk you through the process (in doing so it will, hopefully, help you solve your own problems) -- not that there is much of a process as it is frankly, really basic HTML. > > > I have a listbox which I populate from a query with the database. It is > > > working fine. But additinally, I want the first item to be "Select > > > category". Can someone please help me how to modify by below written > > code > > > > to do the above? Can I assume that you are at least familiar with basic HTML? If not, then you really ought get up to speed on HTML before playing with PHP. OK, you want to display a select box. A properly written select box would look something like: Basket Bathroom Bird feeder You want to add an extra option to it, AND you want the extra item to be displayed first, so it would now look like: ANY CATEGORY Basket Bathroom Bird feeder So, look at your code and determine how/where you would insert that extra item. I've already indicated previously _where_ the extra code should go, and also hinted at _how_. It is a simple matter for you to fill in the blanks (or ... to be precise). Also, do note that your code at present does not output well formed HTML. You may want to fix that. > > > My code : Quote : > > > > > > > > > > > //connecting to the database > > > $link = mysql_connect("localhost","MyDomain","MyPass"); > > > if ($link){ > > >Print ""; > > >} else { > > >Print "No connection to the database"; > > >} > > >if (!mysql_select_db("MyDomain_com")){ > > > Print "Couldn't connect database"; > > > } else { > > > Print ""."\n"; > > > } > > > > echo " > > > > $sql="SELECT DISTINCT CategoryName From Categories ORDER BY > > CategoryName"; > > > > $result=mysql_query($sql); > > > > > > While($Category=mysql_fetch_array($result)) > > > { > > > Print("$Category[0]\n"); > > > } > > > > > > ?> > > > > > > Unquote -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* "I hope you will find the courage to keep on living despite the existence of this feature." - Richard Stallman */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] question on listbox.
Thanks Jason. Looks like I am too dumb. I still cannot do it. can u please help me further? Thanks Denis - Original Message - From: "Jason Wong" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Saturday, February 01, 2003 8:21 PM Subject: Re: [PHP] question on listbox. > On Saturday 01 February 2003 19:08, Denis L. Menezes wrote: > > Hello friends. > > > > I have a listbox which I populate from a query with the database. It is > > working fine. But additinally, I want the first item to be "Select > > category". Can someone please help me how to modify by below written code > > to do the above? > > > > My code : Quote : > > > > > > > //connecting to the database > > $link = mysql_connect("localhost","MyDomain","MyPass"); > > if ($link){ > >Print ""; > >} else { > >Print "No connection to the database"; > >} > >if (!mysql_select_db("MyDomain_com")){ > > Print "Couldn't connect database"; > > } else { > > Print ""."\n"; > > } > > echo " > > $sql="SELECT DISTINCT CategoryName From Categories ORDER BY CategoryName"; > > $result=mysql_query($sql); > > > > While($Category=mysql_fetch_array($result)) > > { > > Print("$Category[0]\n"); > > } > > > > ?> > > > > Unquote > > -- > Jason Wong -> Gremlins Associates -> www.gremlins.biz > Open Source Software Systems Integrators > * Web Design & Hosting * Internet & Intranet Applications Development * > -- > Search the list archives before you post > http://marc.theaimsgroup.com/?l=php-general > -- > /* > If you are good, you will be assigned all the work. If you are real > good, you will get out of it. > */ > > > -- > 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
Re: [PHP] question on listbox.
- Original Message - From: "Denis L. Menezes" <[EMAIL PROTECTED]> To: "PHP general list" <[EMAIL PROTECTED]> Sent: Saturday, February 01, 2003 6:08 AM Subject: [PHP] question on listbox. Hello friends. >I have a listbox which I populate from a query with the database. It is >working fine. But additinally, I want the first item to be "Select category". >Can someone please help me how to modify by below written code to do > the above? something like this would do it: $valueToSelect = 'foo'; { Print("{$Category[0]}\n"); } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] question on listbox.
On Saturday 01 February 2003 19:08, Denis L. Menezes wrote: > Hello friends. > > I have a listbox which I populate from a query with the database. It is > working fine. But additinally, I want the first item to be "Select > category". Can someone please help me how to modify by below written code > to do the above? > > My code : Quote : > > > //connecting to the database > $link = mysql_connect("localhost","MyDomain","MyPass"); > if ($link){ >Print ""; >} else { >Print "No connection to the database"; >} >if (!mysql_select_db("MyDomain_com")){ > Print "Couldn't connect database"; > } else { > Print ""."\n"; > } echo " $sql="SELECT DISTINCT CategoryName From Categories ORDER BY CategoryName"; > $result=mysql_query($sql); > > While($Category=mysql_fetch_array($result)) > { > Print("$Category[0]\n"); > } > > ?> > > Unquote -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* If you are good, you will be assigned all the work. If you are real good, you will get out of it. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php