Jump to content

sort by


An7hony

Recommended Posts

Hi I have 2 jump menus which im using for sort by

 

Sown below the jump menus:

 

<select name="select" onChange="MM_jumpMenu('parent',this,1)" class="basic-combo" >
              <option value="#" selected>All Locations</option>
              <option value="/index.php?view=jobs&location=1">Lincoln</option>
              <option value="/index.php?view=jobs&location=2">Mansfield</option>
      <option value="/index.php?view=jobs&location=3">Grantham</option>
            </select>

 

and

 

<select name="select" onChange="MM_jumpMenu('parent',this,1)" class="basic-combo" >
              <option value="#" selected>Sort By. . .</option>
              <option value="/index.php?view=jobs">All Job Types</option>
              <option value="/index.php?view=jobs&sort=1">Temporary</option>
              <option value="/index.php?view=jobs&sort=2">Permanent</option>
      <option value="/index.php?view=jobs&sort=3">Perm to Temp</option>
            </select>

 

Here is my php

 

<?php
$sortbylocation = intval($_GET['location']);

      switch ($sortbylocation)
      {
      case 1:
      {
      $sortlocation = "WHERE branch = 'Lincoln'";
      };break;

      case 2:
      {
      $sortlocation = "WHERE branch = 'Mansfield'";
      };break;
  
  case 3:
      {
      $sortlocation = "WHERE branch = 'Grantham'";
      };break;

      //etc with the rest of the attributes

      }




      $sortby = intval($_GET['sort']);

      switch ($sortby)
      {
      case 1:
      {
      $sqlExtra = "WHERE jobtype = 'Temporary'";
      };break;

      case 2:
      {
      $sqlExtra = "WHERE jobtype = 'Permanent'";
      };break;
  
  case 3:
      {
      $sqlExtra = "WHERE jobtype = 'Temp to Perm'";
      };break;

      //etc with the rest of the attributes

      }
?>

 

and where its sorting:

 

<?php
$sql = "SELECT id, agent, branch, title, location, salary_from, salary_to, frequency, jobtype, description, specifications, benefits, email, created_at, categories FROM $tbl_name ".$sortlocation." ".$sqlExtra." LIMIT $start, $limit";
$result = mysql_query($sql);
?>

 

question is how do i make the second menu dependant on the first menu option?

Link to comment
https://forums.phpfreaks.com/topic/202727-sort-by/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.