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:

  <select name="category">
    <option value="0000000028">Basket</option>
    <option value="0000000021">Bathroom</option>
    <option value="0000000008">Bird feeder</option>
  </select>

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:

  <select name="category">
    <option value="%">ANY CATEGORY</option>
    <option value="0000000028">Basket</option>
    <option value="0000000021">Bathroom</option>
    <option value="0000000008">Bird feeder</option>
  </select>

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 :
> > >
> > >
> > > <?php
> > >     //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 ""."<br>\n";
> > >  }
> >
> >   echo "<option ...";
> >
> > > $sql="SELECT DISTINCT CategoryName From Categories ORDER BY
>
> CategoryName";
>
> > > $result=mysql_query($sql);
> > >
> > > While($Category=mysql_fetch_array($result))
> > >  {
> > >  Print("<OPTION VALUE=\"$Category[0]\">$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

Reply via email to