If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 2 of 2
  1. #1
    Member mikedfunk's Avatar
    Join Date
    May 2003
    Orlando, FL
    Member #
    I am trying to show a drop-down box that has options to show all and some other options to limit results. For instance:

    All<-initially selected
    Business Cards

    This is within a form with a submit button. The selected item would query a MySQL table for the results, but I can't seem to make the "All" function work.

    The problem is in the MySQL query, in the WHERE part. I can't seem to make the WHERE query a wildcard for all. How do I do this?

    I could type out everything I've already got working correctly, but that would take a long time and you don't want to read all that anyway. Please assume I already have a connection, etc. Everything works but the "All" query.

    Any suggestions? Your help is most appreciated.
    "That's what you get for messing around with the Yakuzas!"


  3. #2
    Senior Member rosland's Avatar
    Join Date
    Jul 2003
    Member #
    Why would you want a WHERE limitation if you are to select all?

    What you could do instead is to write either one query with separate query "add ons" (WHERE something='something') or several separate complete queries.

    Before query execution in your PHP code, you add a Switch($option_variable) statement with Case-clauses determining which (if any) WHERE-conditions are to be added to the basic query (or which of the different complete queries that are to be used).
    PHP Code:
    $base_query="SELECT [i]columns[/i] FROM [i]tablename[/i]";
    $opt1="WHERE [i]something[/i]='[i]some_limit[/i]' ";
    $opt2="WHERE [i]some_other_thing[/i]='[i]some_other_limit[/i]' ";

    $option="something"$sql=$base_query.$opt1; break;
    $option="something_else"$sql=$base_query.$opt2; break;
    # And so forth
    default: $sql=$base_query;} 
    S. Rosland

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
All times are GMT -6. The time now is 07:09 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2020 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: