Link to home
Start Free TrialLog in
Avatar of Addie Baker
Addie BakerFlag for United States of America

asked on

How to use multiple queries based on users selection

I have a highcharts chart im using to display number of downloads on apps. The chart is being populated by mysql query.

I have 2 bootstrap dropdown-menu's for that chart. one is date range, and the other is app. The app is populated by a sql query.

Each one of these dropdown's work fine independently. i want them to work together. So if the user chooses a app then a date it will keep track of both.

Here is how im handling the $GET's now

if (isset($_GET['id'])) {
    $app = $_GET['id'];
    $array2 = explode('/', $app);
    $activity = $array2[0];
    $app_name = $array2[1];
    $SQL= " SELECT blah blah blah WHERE activity = ' $activity' ";
} else if (isset($_GET['date'])) {
      $daterange = $_GET['date'];
              if ($daterange = "thisyear"){
               $SQL =
               }
              if ($daterange = "lastyear"){
               $SQL =
               }
} else {
    $SQL = 
}

Open in new window


I can provide more info if needed.
ASKER CERTIFIED SOLUTION
Avatar of Tom Beck
Tom Beck
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Addie Baker

ASKER

okay. I understand this and will work well.

However, you put the WHERE on the first line of $SQL. when table initially loads it won't have a where clause.

Also you put AND if $_GET date exists. What if there is only app chosen and no date? or date and no app?