help with a search page

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Matthew Robinson

    help with a search page

    the page below returns just the search box everytime. ive not attempted to
    code the text search yet, but i want it to beable to filter out the
    category's, but its just not showing any. any idea's any1? TIA




    <body bgcolor="#8C999 B">
    <?php
    $for = $_GET['for'];
    $catagory = $_GET['catagory'];
    ?>

    <div align=center>
    <form action="<?php $PHP_SELF ?>" method="GET"> <br><table
    bgcolor="#FFF8D 7" cellpadding=6>
    <tr> <td> </td> </tr> <tr> <td> <div align=center> Search For:
    </div></td> <td> <div align=center> Catagory: </div></td> </td>
    </tr> <tr> <td>
    <INPUT name=for value=<?php echo ("$for"); ?>>
    </td> <td>
    <SELECT NAME=catagory SIZE=1>
    <OPTION SELECTED>Search All Catagories <OPTION>Flora l
    Creations
    <OPTION>Decorat ive Lighting
    <OPTION>Kitchen ware & Crockery
    <OPTION>Fancy Goods & Furniture
    </SELECT>
    </td> <td>
    <INPUT TYPE=submit VALUE="Search">
    </td>
    </form>
    <tr> <td> </td> </tr>
    </table>
    </div>


    <?php if (empty($_GET['catagory'])) { exit; }

    $search_catagor y = $_GET['catagory']; $search_for = $_GET['for'];

    $dbcnx = @mysql_connect( "a", "b", "c"); $select =
    @mysql_select_d b("houseproudla ncs_co_uk1");



    switch ($search_catago ry) {
    case "Search All Catagories":
    $filter_catagor y = "*" ;
    break;
    case "Floral Creations":
    $filter_catagor y = "floral";
    break;
    case "Decorative Lighting":
    $filter_catagor y = "lighting";
    break;
    case "Kitchenwar e & Crockery":
    $filter_catagor y = "kitchenwar e";
    break;
    case "Fancy Goods & Furniture":
    $filter_catagor y = "furniture" ;
    break;
    default:
    echo ("<P> Filter Catagory Didn't Match Anything </P>"); echo
    ("$search_catag ory");
    echo ("$filter_catag ory");
    break;
    }


    $command = "SELECT * FROM stock WHERE 1 AND 'catagory' =
    \"$filter_catag ory\" ORDER BY `id`"; $qresult = mysql_query($co mmand)
    or die(mysql_error ()); echo ("<center><tabl e width=80%
    cellpadding=5>" ); $tablebgcolor = "#FFF8D7";
    while ($row = mysql_fetch_arr ay($qresult)) {

    if ($tablebgcolor == "#FFF8D7"){ //yellow
    $tablebgcolor = "#C5C8FF"; //blue
    } else {
    $tablebgcolor = "#FFF8D7";
    } ?>

    <tr ><td> <table border=0 cellspacing=3 width=100% bgcolor=<?php
    echo ("$tablebgcolor "); ?>> <tr><td> <table> <tr>

    <td><pre>Name : </pre></td> <td><b><?php echo ($row
    ["name"]); ?></b> </td></tr><tr> <td><pre>Descri ption:
    </pre></td> <td><?php echo ($row ["descriptio n"]); ?>
    </td></tr><tr> <td><pre>Catago ry: </pre></td> <td><?php echo
    ($row ["catagory"]); ?> </td></tr><tr> <td><pre>Pric e:
    £</pre></td> <td><?php echo ($row ["price"]); ?>
    </td></tr><tr> <td><pre>P&P: £</pre></td> <td><?php echo
    ($row ["pandp"]); ?> </td></tr><tr>
    <?php $quantity = $row ["quantity"];
    if ($quantity != "0") { ?>
    <td><pre>Quanti ty: </pre></td> <td><?php echo ($row
    ["quantity"]); ?> </td></tr><tr><?php } ?>
    <td><pre>Produc t ID: </pre></td> <td> <?php echo ($row
    ["id"]); ?> </td></tr><tr><td>
    <?php if ($quantity == "0") { ?>
    <td><b> <font color=#DD0000> Temporarily Out Of Stock
    </b></font></tr><tr>
    <?php } ?>
    </td></tr></table>
    </td><td width=30%>
    <?php $pictureid = $row ["id"]; ?>
    <?php $picturepath = "./images/" . $pictureid . ".jpg"; ?>
    <?php
    if (file_exists($p icturepath)) {
    echo ("<div align=\"center\ "><a href=\"$picture path\"
    target=LargeIma ge><img src=$picturepat h height=200 alt='Image
    Of Product'></a><font size=2><br>Clic k The Image To See It Full
    Size In A New Window</font></div>");
    } else {
    echo ("<div align=\"center\ "><img src=\"/images/nopic.png\"
    height=200 alt='No Picture Available'></a><font
    size=2><br>Sorr y, There Is No Picture Available For This
    Item</font></div>");
    }


    ?>
    </td></tr></table></td></tr>
    <?php } ?>
    </table></center>
  • Erwin Moller

    #2
    Re: help with a search page

    Matthew Robinson wrote:
    [color=blue]
    > the page below returns just the search box everytime. ive not attempted to
    > code the text search yet, but i want it to beable to filter out the
    > category's, but its just not showing any. any idea's any1? TIA
    >
    >
    >
    >
    > <body bgcolor="#8C999 B">
    > <?php
    > $for = $_GET['for'];
    > $catagory = $_GET['catagory'];
    > ?>
    >
    > <div align=center>
    > <form action="<?php $PHP_SELF ?>" method="GET"> <br><table[/color]


    Try:
    <?php echo $PHP_SELF ?>
    instead of
    <?php $PHP_SELF ?>

    In general: Always check your HTML-ourput generated by PHP when debugging.
    You'll see the action-field is empty.

    I didn't look futher, but maybe this helps.

    Regards,
    Erwin Moller

    Comment

    • Agelmar

      #3
      Re: help with a search page

      Erwin Moller wrote:[color=blue]
      > Matthew Robinson wrote:
      >[color=green]
      >> the page below returns just the search box everytime. ive not
      >> attempted to code the text search yet, but i want it to beable to
      >> filter out the category's, but its just not showing any. any idea's
      >> any1? TIA
      >>
      >>
      >>
      >>
      >> <body bgcolor="#8C999 B">
      >> <?php
      >> $for = $_GET['for'];
      >> $catagory = $_GET['catagory'];[color=darkred]
      >>>[/color]
      >>
      >> <div align=center>
      >> <form action="<?php $PHP_SELF ?>" method="GET"> <br><table[/color]
      >
      >
      > Try:
      > <?php echo $PHP_SELF ?>
      > instead of
      > <?php $PHP_SELF ?>
      >
      > In general: Always check your HTML-ourput generated by PHP when
      > debugging. You'll see the action-field is empty.
      >
      > I didn't look futher, but maybe this helps.
      >
      > Regards,
      > Erwin Moller[/color]

      Actually, since I'm guessing that he has register_global s off (as everyone
      should), make it
      echo $_SERVER['PHP_SELF'];


      Comment

      • Matthew Robinson

        #4
        Re: help with a search page

        i took out php_self alltogether and replaced it with a relative link to
        itself ( ACTION="./search.php" ) and that didn't work either - same
        outcome. the variables are being passed between the pages because the url
        is ../search.php?for= &category=Flora l+Creations

        Comment

        • Matthew Robinson

          #5
          Re: help with a search page

          in the html form, it said this ...ACTION=" "... so i took out the php_self
          variable and replaced it with the relative link to the page in html (
          ...ACTION="./search.php"... but i stil have the same problem.

          Comment

          • steven mestdagh

            #6
            Re: help with a search page

            Matthew Robinson <mattyrobinson6 9@hotmail.com> wrote:[color=blue]
            > the page below returns just the search box everytime. ive not attempted to
            > code the text search yet, but i want it to beable to filter out the
            > category's, but its just not showing any. any idea's any1? TIA
            >
            > <SELECT NAME=catagory SIZE=1>
            > <OPTION SELECTED>Search All Catagories <OPTION>Flora l
            > Creations
            > <OPTION>Decorat ive Lighting
            > <OPTION>Kitchen ware & Crockery
            > <OPTION>Fancy Goods & Furniture
            > </SELECT>[/color]

            i think you need to use <option value="my_optio n">just an option</option>
            in this select statement. then the value will be in the $_GET array.

            steven.

            Comment

            • Matthew Robinson

              #7
              Re: help with a search page

              On Fri, 09 Jan 2004 15:25:22 +0000, steven mestdagh wrote:
              [color=blue]
              > Matthew Robinson <mattyrobinson6 9@hotmail.com> wrote:[color=green]
              >> the page below returns just the search box everytime. ive not attempted to
              >> code the text search yet, but i want it to beable to filter out the
              >> category's, but its just not showing any. any idea's any1? TIA
              >>
              >> <SELECT NAME=catagory SIZE=1>
              >> <OPTION SELECTED>Search All Catagories <OPTION>Flora l
              >> Creations
              >> <OPTION>Decorat ive Lighting
              >> <OPTION>Kitchen ware & Crockery
              >> <OPTION>Fancy Goods & Furniture
              >> </SELECT>[/color]
              >
              > i think you need to use <option value="my_optio n">just an option</option>
              > in this select statement. then the value will be in the $_GET array.
              >
              > steven.[/color]

              thats not the problem - ive tried echoing the contents of catagory from
              the GET array, and it shows up whatever was pressed.

              Comment

              • Agelmar

                #8
                Re: help with a search page

                Matthew Robinson wrote:[color=blue]
                > On Fri, 09 Jan 2004 15:25:22 +0000, steven mestdagh wrote:
                >
                >[color=green]
                >>Matthew Robinson <mattyrobinson6 9@hotmail.com> wrote:
                >>[color=darkred]
                >>>the page below returns just the search box everytime. ive not attempted to
                >>>code the text search yet, but i want it to beable to filter out the
                >>>category's , but its just not showing any. any idea's any1? TIA
                >>>
                >>> <SELECT NAME=catagory SIZE=1>
                >>> <OPTION SELECTED>Search All Catagories <OPTION>Flora l
                >>> Creations
                >>> <OPTION>Decorat ive Lighting
                >>> <OPTION>Kitchen ware & Crockery
                >>> <OPTION>Fancy Goods & Furniture
                >>> </SELECT>[/color]
                >>
                >>i think you need to use <option value="my_optio n">just an option</option>
                >>in this select statement. then the value will be in the $_GET array.
                >>
                >>steven.[/color]
                >
                >
                > thats not the problem - ive tried echoing the contents of catagory from
                > the GET array, and it shows up whatever was pressed.[/color]

                What he's saying is that your code is not valid HTML.
                the syntax is (lowercase):
                <select name="category" >
                <option value="all" selected="selec ted">Search All Categories</option>
                <option value="decorati ve">Decorativ e Lighting</option>
                ....
                </select>

                If it works, it shouldn't, and you're likely using Internet Explorer or
                something that is trying to work with your broken HTML.

                If you're saying that you do echo $_GET['category'] and it actually
                shows up, then what is your question???

                Comment

                • Matthew Robinson

                  #9
                  Re: help with a search page

                  i found the problem - the question was to make it pull only the selected
                  stuff out of the database (before it was getting nothing for the db) - the
                  problem was actually in the mysql command (in the $command variable).
                  thanks anyway

                  Comment

                  • Pedro Graca

                    #10
                    Re: help with a search page

                    Matthew Robinson wrote:[color=blue]
                    > $command = "SELECT * FROM stock WHERE 1 AND 'catagory' =
                    > \"$filter_catag ory\" ORDER BY `id`";[/color]

                    Do not use ' (single quotes) for the column name. If you must
                    delimit it use ` (backticks).

                    select * from stock where 1 and catagory="somet hing" ...

                    select * from stock where 1 and `catagory`="som ething" ...
                    --
                    --= my mail box only accepts =--
                    --= Content-Type: text/plain =--
                    --= Size below 10001 bytes =--

                    Comment

                    • John Dunlop

                      #11
                      Re: help with a search page

                      steven mestdagh wrote:
                      [color=blue]
                      > Matthew Robinson <mattyrobinson6 9@hotmail.com> wrote:[color=green]
                      > >
                      > > <SELECT NAME=catagory SIZE=1>
                      > > <OPTION SELECTED>Search All Catagories <OPTION>Flora l
                      > > Creations
                      > > <OPTION>Decorat ive Lighting
                      > > <OPTION>Kitchen ware & Crockery
                      > > <OPTION>Fancy Goods & Furniture
                      > > </SELECT>[/color]
                      >
                      > i think you need to use <option value="my_optio n">just an option</option>
                      > in this select statement. then the value will be in the $_GET array.[/color]

                      No. There's nothing technically wrong with the above HTML excerpt,
                      it's perfectly valid and should be understood by any browser worth
                      its salt. (I'm not sure why "size=1" is specified though.) If an
                      option element doesn't have a value attribute, the content of the
                      element is used as the initial value (HTML4.01 sec. 17.6.1).

                      --
                      Jock

                      Comment

                      • michael nieuwenhuizen

                        #12
                        Re: help with a search page


                        "Agelmar" <ifetteNOSPAM@c omcast.net> wrote[color=blue]
                        >[color=green][color=darkred]
                        >>> <form action="<?php $PHP_SELF ?>" method="GET"> <br><table[/color]
                        >> <?php echo $PHP_SELF ?>[/color]
                        > echo $_SERVER['PHP_SELF'];[/color]

                        shouldn't it simply be:
                        <form action="<?php $_SERVER['PHP_SELF'] ?>" ... ?

                        mike

                        --
                        newbie


                        Comment

                        Working...