Jump to content

Need Help Folks


sullyman

Recommended Posts

Folks,

 

Please can someone help.

 

I have two dropdown lists that is nearly working on http://www.add.ie/IrishServices.php

 

The problem is that the first dropdown list doesn't group the Service Types so for every hospital i enter for the city of Cork for example, it lists another entry for hospital in the dropdownlist. I just want to have one entry for hospital in the Services list dropdown so when i choose a city in the second dropdownlist (Cork for example, all hospitals for Cork are returned)

 

I have placed the code below. Can someone please help?

 

Sully

 

 

 

<?php

$Today=Date('j M Y');

$Filter_County="*";

$Filter_Service="*";

$Filter_Service="*";

$WhereClause="";

if (isset($_SESSION['Filter_County'])){$Filter_County=$_SESSION['Filter_County'];}

if (isset($_POST['Filter_County'])){$Filter_County = $_POST['Filter_County'];}

  else {if (isset($_GET['Filter_County'])) {$Filter_County = @$_GET['Filter_County']; }}

$_SESSION['Filter_County']=$Filter_County;

if (isset($_SESSION['Filter_Service'])){$Filter_Service=$_SESSION['Filter_Service'];}

if (isset($_POST['Filter_Service'])){$Filter_Service = $_POST['Filter_Service'];}

  else {if (isset($_GET['Filter_Service'])) {$Filter_Service = @$_GET['Filter_Service']; }}

$_SESSION['Filter_Service']=$Filter_Service;

?>

 

 

 

 

 

<?php

$Action="SORT";

$SortOrder="Name";

$CurrentSortOrder="";

$CurrentDirection="ASC";

$i1=$i2=$i3=$i4=$i5="&nbsp&nbsp";

foreach($_GET as $key=>$value) {$$key = $value;}

if ($SortOrder==$CurrentSortOrder){

if ($CurrentDirection=="ASC"){$CurrentDirection="DESC";}

else{$CurrentDirection="ASC";}

} else {$CurrentDirection="ASC";}

if ($CurrentDirection=="ASC"){$i="<img src='Images/ascend.gif'>";$ReverseDirection="DESC";}

else {$i="<img src='Images/descend.gif'>";$ReverseDirection="ASC";}

if ($Action=="SORT"){

switch ($SortOrder){

  case "ID";

  $OrderBy = "INF_Number";

  $i1=$i;

  break;

  case "Name";

  $OrderBy = "INF_Name";

  $i2=$i;

  break;

  case "Town";

  $OrderBy = "INF_Town,INF_Name";

  $i3=$i;

  break;

  case "County";

  $OrderBy = "INF_County,INF_Name";

  $i4=$i;

  break;

  case "Type";

  $OrderBy = "INF_Type,INF_Name";

  $i5=$i;

  break;

}

}

?>

 

<td>

  <table>

    <?php

    $Action="SORT";

  //  $SortOrder="Name";

  //  $CurrentSortOrder="";

  //  $CurrentDirection="ASC";

  //  $i1=$i2=$i3=$i4=$i5="&nbsp&nbsp";

    ?>

    <td>

      <table>

      <tr>

        <td align=left> <b>Select</b>

  <?php

        echo ("<td><SELECT NAME='Filter_Service' onchange='submit()'>\n");

        if ($Filter_Service=="*"){echo("<OPTION VALUE='*' selected >------------------All------------------\n");

        }else{echo("<OPTION VALUE='*' >------------------All------------------\n");}

        echo ("<OPTION VALUE='None'>None\n");

        $query3 = "SELECT INF_Type FROM IreInfobase ORDER BY INF_Type";

        if (openDB(DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, $connection)){

        if (($result3 = mysql_query($query3, $connection))){

        while ($row3 = mysql_fetch_array($result3, MYSQL_ASSOC)){

        foreach($row3 as $key=>$value) {$$key = $value;}

        if ($Filter_Service==$INF_Type){echo ("<OPTION VALUE='$INF_Type' selected>$INF_Type\n");

      }else{echo ("<OPTION VALUE='$INF_Type'>$INF_Type\n");}

    }

      mysql_free_result($result3);

    } else {

    error("Error reading IreInfobase table ".mysql_error()."<br>");

  }

  closeDB($connection);

  } else {error ("Error opening DB ".mysql_error());}

echo ("</SELECT></td>\n");

?>

</td>

     

      <?php

        if ($Filter_County=="Cork"){$s1="selected";}else{$s1="";}

        if ($Filter_County=="Dublin"){$s2="selected";}else{$s2="";}

        if ($Filter_County=="Limerick"){$s3="selected";}else{$s3="";}

        ?>

        <td align=left> <b>Select</b>

        <SELECT name="Filter_County" onchange='submit()'>

          <OPTION VALUE='*' <?=$s9?>> County

          <OPTION VALUE='Cork' <?=$s1?>>Cork

          <OPTION VALUE='Dublin' <?=$s2?>>Dublin

          <OPTION VALUE='Limerick' <?=$s3?>>Limerick

        </SELECT>

        <?php

        $And="";

        if ($Filter_Service<>"*" OR $Filter_County<>"*"){

        $WhereClause="WHERE ";

        }

        if ($Filter_Service<>"*") {

        $WhereClause.="INF_Type='".$Filter_Service."'";

        $And=" AND ";

        }

        if ($Filter_County<>"*") {

        $WhereClause.=$And."INF_County='".$Filter_County."'";

        }

        $query="SELECT INF_Number,

                INF_Type,

                INF_Name,

                INF_Description,

                INF_Addrno,

                INF_Addr,

                INF_Town,

                INF_Postcode,

                INF_County,

                INF_Contno,

                INF_Contfx,

                INF_Contem,

                INF_Webaddr,

                INF_Notes,

                INF_Gridref,

                INF_Latitude,

                INF_Longitude

          FROM IreInfobase

              ".$WhereClause."

      ORDER BY ".$OrderBy." ".$CurrentDirection;

      $CurrentSortOrder=$SortOrder;

      ?>

Link to comment
https://forums.phpfreaks.com/topic/43446-need-help-folks/
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.