SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 1999
    Location
    Munster
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have set up a new website using a database. I am not sure how i would display all results. I have my site on the front with drop down menus. But i am not sure how to do a search that will display all results. If you can look at http://www.webcitynet.com/food there is a spot that has display all. I have the other parts of the pull downs working. But dont know how to do the search for all. Any help is appreciated.

  2. #2
    SitePoint Zealot
    Join Date
    Nov 1999
    Location
    Manhattan!
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am not quite sure what you mean by displaying all the results (and why...). But if you want to get all the records from a table called my_food then just do:

    $result = mysql_query("SELECT * FROM my_food");

    Christian

  3. #3
    SitePoint Enthusiast
    Join Date
    Dec 1999
    Location
    Munster
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So what would i set the option value for the pull down menu "dislpay all"?? Just wondering. I understand how to display all results if i am using mysql but not with a pull down menu. Thanks

    Dave

  4. #4
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Set the value of your "Display all" option to "" (the empty string). Then, in your PHP, you can use a special "select all" SQL query when you detect this empty string value.

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">code/font><HR><pre>if ($searchcat == "") {
    $sql = "SELECT * FROM tblName";
    } else {
    $sql = "SELECT * FROM tblName WHERE...";
    }
    $result = mysql_query($sql);[/code]

    ------------------
    -Kevin Yank.
    http://www.SitePoint.com/
    Helping Small Business Grow Online!

  5. #5
    SitePoint Zealot
    Join Date
    Jun 2000
    Posts
    165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi there,

    If you want to display all results, put the results in an array and then loop through them......

    Cheers


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •