Jump to content

DSTR3

Members
  • Posts

    53
  • Joined

  • Last visited

Posts posted by DSTR3

  1. Closer, but still not the image.....

    http://www.menuhead.net/PopUP/mouseover-popup/overthis.php

     

    <td><a href ='#' id='trigger'('$row[LocationPix]');><img src='http://www.menuhead.net/Images/Buttons/PShotClear.png'</td>
    

     

    $(function() {
     var moveLeft = 20;
     var moveDown = 10;
     $('a#trigger').hover(function(e) {
       $('div#pop-up').show();
     }, function() {
       $('div#pop-up').hide();
     });
     $('a#trigger').mousemove(function(e) {
       $("div#pop-up").css('top', e.pageY + moveDown).css('left', e.pageX + moveLeft);
     });
    });
    

     

    Now how to get the picture?

  2. I am trying to do a mouseover/mouseout on an image in a table. Right now I have it working with Javascript. You click on the camera and the image comes up in a new window. However; I want to do it with a mouseover like this.

     

    http://www.menuhead.net/PopUP/mouseover-popup/over.php

     

    I know mouseover is client side so how would I do this with php.

     

    function newPopup(url) {
    popupWindow = window.open(
     url,'popUpWindow','height=300,width=300,left=10,top=10,resizable=no,scrollbars=no,toolbar=no,menubar=no,location=no,directories=no,status=no'  )
    }
    

     

    <td><a href=Javascript:newPopup('$row[LocationPix]');><img src='http://www.menuhead.net/Images/Buttons/PShotClear.png'</td>
    

     

    Thank you.

  3. fenway. Here is the solution I came up with. First I take all of te records that meet the criteria and insert them into them into a temp table. Then I do a count of how many times the LcationID appears and compare that against the number options that were selected. Then I run the query with those that equal the number of selected options. See what you think.

     

    <form method="post" name="Critters" id="Critters">
       <p align="center">
      <select name>
      </select>
        <select name>
      </select>
        <select>
      </select>
     </p>
       <p align="center">
    
    
    
      <select name="criteria[]" multiple="multiple">
        <?php
       include("config.php");
       ///////With Numbers/////
       //$sql = "SELECT DISTINCT DetailType AS type, DetailID, DetailName FROM tblDetails
       //ORDER BY DetailType, DetailName";
       //		 $result = mysql_query($sql) or die(mysql_error());
       //   $prev='';
       //   while ($row = mysql_fetch_assoc($result)) {
       //   if ($prev != $row['type']) {
       //    if ($prev) echo "</optgroup>";
       //    echo "<optgroup label='{$row['type']}'>";
       //    $prev = $row['type'];
       //    }
       //    echo "<option value='".$row['DetailID']."'>".$row['DetailName']."</option>";		   //    }
       //    echo "</optgroup>";
       //Without Numbers/////
       //This builds the dropdown based on City, Area, and Cuisiner for the results_city.php file
       $sql = "SELECT DetailType AS type, DetailID, GROUP_CONCAT(DISTINCT DetailName
       ORDER BY DetailName ASC 
       SEPARATOR '|') AS DetailName FROM tblDetails GROUP BY DetailType";
       $result = mysql_query($sql) or die(mysql_error()); 
       while ($row = mysql_fetch_assoc($result)){
       {
     var_dump($row);
       }
       echo "<optgroup label='{$row['type']}'>";
       $DetailNames = explode('|', $row['DetailName']);
       foreach($DetailNames as $DetailName)
       {
    	 echo "<option value='".$DetailName."'>".$DetailName."</option>";
       }
       echo "</optgroup>";
       } 
       ?>
      </select>
       </p>
     <p align="center"><input type="submit" name="btnSearch" id="btnSearch"
      value="		  SEARCH		  "></p>
     </form>
    
     <p>
       <?php
     //This is for the button///////////////////////////////////
     if (isset ( $_POST ["btnSearch"] )) {
     echo "<br>Selected Options are :<br>";
     $checked = $_POST ["criteria"];
    
     $criteria = "";
     $separator = ", ";
     for($i = 0; $i < count ( $checked ); $i ++) {
     echo " " . $checked [$i] . "<br/>";
    
     if ($i == count ( $checked ) - 1) {
      $separator = "";
     }
     $criteria = $criteria . "'" . $checked [$i] . "'" . $separator;
     }
     //This gives a count of the number of options that have been selected////////////////////////
     $nchecked = count($checked);
     echo("<p>$nchecked filter(s) HEROselected:<br>");
     for($i=0; $i < $nchecked; $i++)
     {
     echo($checked[$i] . "<br/>");
     }
     echo("</p>");
     //END COUNT////////////////////////////////////
     echo "<br><br>";
     echo $criteria . "<br><br>";
     include "config.php"; 
     $mysqlQuery = "INSERT into tblTemp (LocationID,DetailID,DetailName)
     SELECT tblLocDet.LocationID, tblLocDet.DetailID, tblDetails.DetailName
     FROM tblLocDet
     INNER JOIN tblDetails ON tblLocDet.DetailID = tblDetails.DetailID
     WHERE tblDetails.DetailName IN (" . $criteria . ");";
     mysql_query($mysqlQuery);
    
    
     $mysqlQuery2 = "SELECT tblTemp.LocationID, tblRestaurants.RestName,
      CONCAT(tblLocations.StreetNumber,'  ', tblLocations.Street) AS Address, tblLocations.Phone, 
      tblLocations.Price, tblLocations.Rating
      FROM (tblRestaurants INNER JOIN tblLocations ON tblRestaurants.RestID = tblLocations.RestID)
      INNER JOIN tblTemp ON tblLocations.LocationID = tblTemp.LocationID
      GROUP BY tblTemp.LocationID
      HAVING Count(tblTemp.LocationID) = '$nchecked'
      ORDER BY tblRestaurants.RestName";
     //$mysqlQuery2 = ("SELECT tblTemp.LocationID, Count(tblTemp.LocationID) AS CountOfLocationID
     //  FROM tblTemp
     //   GROUP BY tblTemp.LocationID
     //   HAVING Count(tblTemp.LocationID) = '$nchecked'");
     mysql_query($mysqlQuery2);  
    
     if (! $rs = mysql_query ( $mysqlQuery2 )) {
      echo "Cannot parse query";
      } elseif (mysql_num_rows ( $rs ) == 0) {
       echo "No records found";
     } else {
     echo (mysql_error());
      echo "<table id=\"myTable\" table width=\"710\" class=\"beautifuldata\" align=\"Left\"
      cellspacing=\"0\">\n";
      echo "<thead>\n<tr>";
      echo "<th>PLACE</th>";
      echo "<th>ADDRESS</th>";
      echo "<th>PHONE</th>";
      echo "<th>PRICE</th>";
      echo "<th>RATING</th>";
      echo "</tr>\n</thead>\n";
      while ( $row = mysql_fetch_array ( $rs ) ) {
      echo"<tr>
      <td><strong><a href='$row[RestPage]'>$row[RestName]</a></strong></td>
      <td>$row[Address]</td>
      <td>$row[Phone]</td>
      <td>$row[Price]</td>
      <td>$row[Rating]</td>
      </tr>\n";
      }
      echo "</table><br />\n";
      }
      $mysqlQuery3 = "DELETE FROM tblTemp";
      mysql_query($mysqlQuery3);
      mysql_close ();
      }
     ?>
     </p>
    </body>
    

  4. I'm done. This works! Thank you everyone. Especially you DavidAM.

     

    include "config.php"; 
     $mysqlQuery = "INSERT into tblTemp (LocationID,DetailID,DetailName)
     SELECT tblLocDet.LocationID, tblLocDet.DetailID, tblDetails.DetailName
     FROM tblLocDet
     INNER JOIN tblDetails ON tblLocDet.DetailID = tblDetails.DetailID
     WHERE tblDetails.DetailName IN (" . $criteria . ");";
     mysql_query($mysqlQuery);
    
     $mysqlQuery2 = ("SELECT tblTemp.LocationID, Count(tblTemp.LocationID) AS CountOfLocationID
     FROM tblTemp
     GROUP BY tblTemp.LocationID
     HAVING Count(tblTemp.LocationID) = '$nchecked'");
     mysql_query($mysqlQuery2);  
    
     if (! $rs = mysql_query ( $mysqlQuery2 )) {
      echo "Cannot parse query";
      } elseif (mysql_num_rows ( $rs ) == 0) {
       echo "No records found";
     } else {
     echo (mysql_error());
      echo "<table id=\"myTable\" table width=\"710\" class=\"beautifuldata\" align=\"Left\"
      cellspacing=\"0\">\n";
      echo "<thead>\n<tr>";
      echo "<th>PLACE</th>";
      echo "<th>ADDRESS</th>";
      echo "<th>PHONE</th>";
      echo "<th>PRICE</th>";
      echo "<th>RATING</th>";
      echo "</tr>\n</thead>\n";
      while ( $row = mysql_fetch_array ( $rs ) ) {
      echo"<tr>
      <td><strong><a href='$row[RestPage]'>$row[RestName]</a></strong></td>
      <td>$row[LocationID]</td>
      <td>$row[Phone]</td>
      <td>$row[Price]</td>
      <td>$row[Rating]</td>
      </tr>\n";
      }
      echo "</table><br />\n";
      }
      $mysqlQuery3 = "DELETE FROM tblTemp";
      mysql_query($mysqlQuery3);
      mysql_close ();
      }
     ?>
    

  5. OK this is all setup but still getting the error message cannot parse query. I run the query2 in Navicat and the recorda come up fine. The only thing that I am changing is the variable '$nchecked' I even tried a constant, the same that I am using in Navicat and I get the Error 'Cannot Parse Query".....

     

    include "config.php"; 
     $mysqlQuery = "INSERT into tblTemp (LocationID,DetailID,DetailName)
     SELECT tblLocDet.LocationID, tblLocDet.DetailID, tblDetails.DetailName
     FROM tblLocDet
     INNER JOIN tblDetails ON tblLocDet.DetailID = tblDetails.DetailID
     WHERE tblDetails.DetailName IN (" . $criteria . ");";
     mysql_query($mysqlQuery);
    
     if (! $rs = mysql_query ( $mysqlQuery2 )) {
      echo "Cannot parse query";
      } elseif (mysql_num_rows ( $rs ) == 0) {
       echo "No records found";
     } else {
     $mysqlQuery2 = ("SELECT tblTemp.LocationID, Count(tblTemp.LocationID) AS CountOfLocationID
     FROM tblTemp
     GROUP BY tblTemp.LocationID
     HAVING Count(tblTemp.LocationID) == '$nchecked'");
     mysql_query($mysqlQuery2);
     die (mysql_error());
      echo "<table id=\"myTable\" table width=\"710\" class=\"beautifuldata\" align=\"Left\"
      cellspacing=\"0\">\n";
      echo "<thead>\n<tr>";
      echo "<th>LocationID</th>";
      echo "</tr>\n</thead>\n";
      while ( $row = mysql_fetch_array ( $rs ) ) {
      echo "<td>" . $row ['LocationID'] . "</td>";
      echo "</tr>";
      }
      }
      echo "</table><br />\n";
      //$mysqlQuery3 = "DELETE FROM tblTemp";
      //mysql_query($mysqlQuery3);
      mysql_close ();
      }
     ?>
    

  6. OK I did it.....still no go. Message now is cannot parse query. The warning is gone. I suppose its down to that variable &nchecked.?

     

    if (! $rs = mysql_query ( $mysqlQuery2 )) {
    echo "Cannot parse query";
    } elseif (mysql_num_rows ( $rs ) == 0) {
    echo "No records found";
     } else {
     $mysqlQuery2 = ("SELECT tblTemp.LocationID, Count(tblTemp.LocationID) AS CountOfLocationID
     FROM tblTemp
     GROUP BY tblTemp.LocationID
     HAVING Count(tblTemp.LocationID) == '$nchecked'");
     mysql_query($mysqlQuery2);
       echo mysql_error($mysqlQuery2);
    

  7. Tried to place this earlier. Couldn't for some reason.

     

    <?php
    //This is for the button///////////////////////////////////
    if (isset ( $_POST ["btnSearch"] )) {
    echo "<br>Selected Options are :<br>";
    $checked = $_POST ["criteria"];
    
    $criteria = "";
    $separator = ", ";
    for($i = 0; $i < count ( $checked ); $i ++) {
    echo " " . $checked [$i] . "<br/>";
    
    if ($i == count ( $checked ) - 1) {
    $separator = "";
    }
    $criteria = $criteria . "'" . $checked [$i] . "'" . $separator;
    }
    //This gives a count of the number of options that have been selected////////////////////////
    $nchecked = count($checked);
    echo("<p>$nchecked filter(s) HEROselected:<br>");
    for($i=0; $i < $nchecked; $i++)
    {
    echo($checked[$i] . "<br/>");
    }
    echo("</p>");
    //END COUNT////////////////////////////////////
    echo "<br><br>";
    echo $criteria . "<br><br>";
    include "config.php";
    $mysqlQuery = "INSERT into tblTemp (LocationID,DetailID,DetailName)
     SELECT tblLocDet.LocationID, tblLocDet.DetailID, tblDetails.DetailName
     FROM tblLocDet
     INNER JOIN tblDetails ON tblLocDet.DetailID = tblDetails.DetailID
     WHERE tblDetails.DetailName IN (" . $criteria . ");";
    
    
    if (! $rs = mysql_query ( $mysqlQuery )) {
    echo "Cannot parse query";
    } elseif (mysql_num_rows ( $rs ) == 0) {
    echo "No records found";
     } else {
     $mysqlQuery2 = ("SELECT tblTemp.LocationID, Count(tblTemp.LocationID) AS CountOfLocationID
     FROM tblTemp
     GROUP BY tblTemp.LocationID
     HAVING Count(tblTemp.LocationID) == 2");
     mysql_query($mysqlQuery2);
     echo "<table id=\"myTable\" table width=\"710\" class=\"beautifuldata\" align=\"Left\"
     cellspacing=\"0\">\n";
     echo "<thead>\n<tr>";
     echo "<th>LocationID</th>";
     echo "</tr>\n</thead>\n";
     while ( $row = mysql_fetch_array ( $rs ) ) {
     echo "<td>" . $row ['LocationID'] . "</td>";
     echo "</tr>";
     }
     }
     echo "</table><br />\n";
    //$mysqlQuery3 = "DELETE FROM tblTemp";
    //mysql_query($mysqlQuery3);
    mysql_close ();
    }
    ?>
    </p>
    

     

    Still getting this.......

    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/content/d/s/t/dstr3/html/MENUHEAD/Steelers/Czeh.php on line 98

    No records found

  8. So that is why it is working when I move it down! So it must be the variable $nchecked. But also I think its the mysql_numrows perhaps. At this point now.

    <?php
     //This is for the button///////////////////////////////////
     if (isset ( $_POST ["btnSearch"] )) {
     echo "<br>Selected Options are :<br>";
     $checked = $_POST ["criteria"];
    
     $criteria = "";
     $separator = ", ";
     for($i = 0; $i < count ( $checked ); $i ++) {
     echo " " . $checked [$i] . "<br/>";
    
     if ($i == count ( $checked ) - 1) {
      $separator = "";
     }
     $criteria = $criteria . "'" . $checked [$i] . "'" . $separator;
     }
     //This gives a count of the number of options that have been selected////////////////////////
     $nchecked = count($checked);
     echo("<p>$nchecked filter(s) HEROselected:<br>");
     for($i=0; $i < $nchecked; $i++)
     {
     echo($checked[$i] . "<br/>");
     }
     echo("</p>");
     //END COUNT////////////////////////////////////
     echo "<br><br>";
     echo $criteria . "<br><br>";
     include "config.php"; 
     $mysqlQuery = "INSERT into tblTemp (LocationID,DetailID,DetailName)
     SELECT tblLocDet.LocationID, tblLocDet.DetailID, tblDetails.DetailName
     FROM tblLocDet
     INNER JOIN tblDetails ON tblLocDet.DetailID = tblDetails.DetailID
     WHERE tblDetails.DetailName IN (" . $criteria . ");";
    
    
     if (! $rs = mysql_query ( $mysqlQuery )) {
      echo "Cannot parse query";
      } elseif (mysql_num_rows ( $rs ) == 0) {
       echo "No records found";
     } else {
     $mysqlQuery = ("SELECT tblTemp.LocationID, Count(tblTemp.LocationID) AS CountOfLocationID
     FROM tblTemp
     GROUP BY tblTemp.LocationID
     HAVING Count(tblTemp.LocationID) == '$nchecked'");
      echo "<table id=\"myTable\" table width=\"710\" class=\"beautifuldata\" align=\"Left\"
      cellspacing=\"0\">\n";
      echo "<thead>\n<tr>";
      echo "<th>LocationID</th>";
      echo "</tr>\n</thead>\n";
      while ( $row = mysql_fetch_array ( $rs ) ) {
      echo "<td>" . $row ['LocationID'] . "</td>";
      echo "</tr>";
      }
      }
      echo "</table><br />\n";
      //$mysqlQuery3 = "DELETE FROM tblTemp";
      mysql_close ();
      }
     ?>
     </p>
    </body>
    </html>
    

  9. Barand Don't worry about that. I'll adjust the query later. I had it coughing out LocationID earlier. Don't know why it stopped. It's either the position of the queries, the naming of the queries or the variable. If ypu want I can change those output fields. kicken the complete message.

    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/content/d/s/t/dstr3/html/MENUHEAD/Steelers/Czeh.php on line 96

     

     

     

     

  10. Moving things around a bit, I have the first one working, However; the second query has yet to return any results. I made it == cause it has to be equal. not less than or greater than, but equal. Also receiving an ERROR on the line """ elseif (mysql_num_rows ( $rs ) == 0) {""" saying it's not valid.

     

    include "config.php"; 
     $mysqlQuery = "INSERT into tblTemp (LocationID,DetailID,DetailName)
     SELECT tblLocDet.LocationID, tblLocDet.DetailID, tblDetails.DetailName
     FROM tblLocDet
     INNER JOIN tblDetails ON tblLocDet.DetailID = tblDetails.DetailID
     WHERE tblDetails.DetailName IN (" . $criteria . ");";
     if (! $rs = mysql_query ( $mysqlQuery )) {
      echo "Cannot parse query";
      } elseif (mysql_num_rows ( $rs ) == 0) {
       echo "No records found";
     } else {
     $mysqlQuery = ("SELECT tblTemp.LocationID, Count(tblTemp.LocationID) AS CountOfLocationID
     FROM tblTemp
     GROUP BY tblTemp.LocationID
     HAVING Count(tblTemp.LocationID) == '$nchecked'");
      echo "<table id=\"myTable\" table width=\"710\" class=\"beautifuldata\" align=\"Left\"
      cellspacing=\"0\">\n";
      echo "<thead>\n<tr>";
      echo "<th>PLACE</th>";
      echo "<th>ADDRESS</th>";
      echo "<th>PHONE</th>";
      echo "<th>PRICE</th>";
      echo "<th>RATING</th>";
      echo "</tr>\n</thead>\n";
      while ( $row = mysql_fetch_array ( $rs ) ) {
      echo "<tr><td><strong><a href='" . $row [RestPage] . "'>" . $row ['RestName'] . "</a>
      </strong></td>";
      echo "<td>" . $row ['LocationID'] . "</td>";
      echo "<td>" . $row ['Phone'] . "</td>";
      echo "<td>" . $row ['Price'] . "</td>";
      echo "<td>" . $row ['Rating'] . "</td>";
      echo "</tr>";
      }
      }
      echo "</table><br />\n";
      //$mysqlQuery = "DELETE FROM tblTemp";
      mysql_close ();
      }
     ?>
    

  11. Your right! First its suppose to insert records into tblTemp. Its not. Next its suppose to Select records and return the results. its not. Third, its suppose to delete the records from the tblTemp. Its not. Pretty well broke I'd say. I would appreciate your help in this. From what I gather you are VERY knowledgable. Thank you.

     

    PS you were right about this...HAVING Count(tblTemp.LocationID) >= $nchecked

  12. I have three queries that I am trying to run. The first one builds the table tblTemp based on the criteria selected from a multi-select dropdown. This works fine. (Alone) The second one builds the record set based on the count of the options selected in the dropdown. The third one deletes the records from the tblTemp when all is done. For some reason they are not working together. I think its the IF statement thats fouling things up. Have a look.

     

    include "config.php";
     $mysqlQuery = "INSERT into tblTemp (LocationID,DetailID,DetailName)
     SELECT tblLocDet.LocationID, tblLocDet.DetailID, tblDetails.DetailName
     FROM tblLocDet
     INNER JOIN tblDetails ON tblLocDet.DetailID = tblDetails.DetailID
     WHERE tblDetails.DetailName IN (" . $criteria . ");";
    
     $mysqlQuery = ("SELECT tblTemp.LocationID, Count(tblTemp.LocationID) AS CountOfLocationID
     FROM tblTemp
     GROUP BY tblTemp.LocationID
     HAVING Count(tblTemp.LocationID)< $nchecked");
    
     if (! $rs = mysql_query ( $mysqlQuery )) {
      echo "Cannot parse query";
      } elseif (mysql_num_rows ( $rs ) == 0) {
       echo "No records found";
     } else {
      echo "<table id=\"myTable\" table width=\"710\" class=\"beautifuldata\" align=\"Left\"
      cellspacing=\"0\">\n";
      echo "<thead>\n<tr>";
      echo "<th>PLACE</th>";
      echo "<th>ADDRESS</th>";
      echo "<th>PHONE</th>";
      echo "<th>PRICE</th>";
      echo "<th>RATING</th>";
      echo "</tr>\n</thead>\n";
      while ( $row = mysql_fetch_array ( $rs ) ) {
      echo "<tr><td><strong><a href='" . $row [RestPage] . "'>" . $row ['RestName'] . "</a>
      </strong></td>";
      echo "<td>" . $row ['LocationID'] . "</td>";
      echo "<td>" . $row ['Phone'] . "</td>";
      echo "<td>" . $row ['Price'] . "</td>";
      echo "<td>" . $row ['Rating'] . "</td>";
      echo "</tr>";
      }
      }
      echo "</table><br />\n";
      $mysqlQuery = "DELETE FROM tblTemp";
      mysql_close ( $con );
      }
    

  13. I did this and the ERROR I received was "Fatal error: Function name must be a string" on the last line.

     

    $result = mysql_query("SELECT LocationID, count(LocationID) as totalCount
       from tblTemp Group BY LocationID");
      $result = mysql_query($sql) or die("FAIL: $sql <br>" . mysql_error());
      while($row = mysql_fetch_array($result)) {
       if($row['totalCount'] < $nchecked) {
      }
      $mysql_query("DELETE FROM tblTemp WHERE LocationID = '". $row['LocationID'] ."'");
      }
      }
    

  14. Bingo! The errors are gone! But..................of course it's not deleting!

     

    $result = mysql_query("SELECT LocationID, count(LocationID) as totalCount
       from tblTemp Group BY LocationID");
      while($row = mysql_fetch_array($result)) {
       if($row['totalCount'] < $nchecked) {
      }
      $mysql_query("DELETE FROM tblTemp WHERE LocationID = '". $row['LocationID'] ."'");
      }
      }
    

  15. $nchecked is a variable that counts how many options I have selected. Then I am deleting against that value. I will try your suggestion. Thank you. Its still complaining about the foreach line.

     

    $result = mysql_query("SELECT LocationID, count(LocationID) as totalCount
       from tblTemp Group BY LocationID")
      foreach($row = mysql_fetch_array($result)) {
       if($row['totalCount'] < $nchecked) {
      }
      $mysql_query2("DELETE FROM tblTemp WHERE LocationID = '". $row['LocationID'] ."'");
      }
      }
    

  16. I am having problems with the syntax on this. I am counting the number of LocationID's in the tblTemp and if they are less than a certain number I delete them. But my syntax is off.

     

    
    $sql = "SELECT LocationID, count(LocationID) AS totalCount FROM tblTemp GROUP BY LocationID";
    $res = mysql_query($sql) or die("FAIL: $sql <br>" . mysql_error());
    
     foreach($row = mysql_fetch_array($res)) {
      if($row['totalCount'] < (" . $nchecked . ")) {
     }
     $mysql_query2("DELETE FROM tblTemp WHERE LocationID = '". $row['LocationID'] ."'");
     }
     }
    

  17. I need to add DetailID to this. I am having a bit of trouble because this is an Option Group. Any help is appreciated. I need the DetailID to be first, then DetailName, but you should not see the DetaiID, just the DetailName. Thank you.

     

    <?php
       include("config.php");
       //This builds the dropdown based on City, Area, and Cuisiner for the results_city.php file
       $sql = "SELECT DetailType AS type, DetailID, GROUP_CONCAT(DISTINCT DetailName
       ORDER BY DetailName ASC 
       SEPARATOR '|') AS DetailName FROM tblDetails GROUP BY DetailType";
       $result = mysql_query($sql) or die(mysql_error()); 
       while ($row = mysql_fetch_assoc($result)) {
       echo "<optgroup label='{$row['type']}'>";
       $DetailNames = explode('|', $row['DetailName']);
       foreach($DetailNames as $DetailName) {
    	 echo "<option value='".$DetailName."'>".$DetailName."</option>";
       }
       echo "</optgroup>";
       } 
       ?>
    

  18. OK, Closer but no cigar! I am getting all the options that are being asked for except. It's coming out as an OR not an AND.

    Check out this link...

    http://www.menuhead.net/Steelers/2Expert.php

     

    If I put "Fireplace" and Private Room(s) I should get only the places that have both. And the answer is three, But I am getting five results because it's giving me all of the places that have a "Fireplace" AND/OR Private Room(s).

     

    Here is the current code.

     

    <!DOCTYPE unspecified PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <style type="text/css">
    .tblHead {
    background-color: #002DD1;
    color: white;
    text-align: left;
    }
    </style>
    </head>
    <body>
    <p>
     <?php
    if (isset ( $_POST ["btnSearch"] )) {
    echo "<br>Selected Options are :<br>";
    $checked = $_POST ["criteria"];
    
    $criteria = "";
    $separator = ", ";
    for($i = 0; $i < count ( $checked ); $i ++) {
     echo " " . $checked [$i] . "<br/>";
    
     if ($i == count ( $checked ) - 1) {
      $separator = "";
     }
    
     $criteria = $criteria . "'" . $checked [$i] . "'" . $separator;
    }
    echo "<br><br>";
    
    echo $criteria . "<br><br>";
    include "config.php";
    
    mysql_select_db ( "MyHead", $con );
    //$DM = implode(',',$criteria);
    $mysqlQuery = "SELECT tblRestaurants.RestName, tblLocDet.LocationID, tblLocDet.DetailID, tblDetails.DetailName, tblRestaurants.RestName
    FROM tblRestaurants INNER JOIN (tblLocations INNER JOIN (tblLocDet INNER JOIN tblDetails ON tblLocDet.DetailID = tblDetails.DetailID) ON tblLocations.LocationID = tblLocDet.LocationID) ON tblRestaurants.RestID = tblLocations.RestID
    GROUP BY tblRestaurants.RestName, tblLocDet.LocationID, tblLocDet.DetailID, tblDetails.DetailName
    HAVING tblDetails.DetailName IN (" . $criteria . ");";
    
    if (! $rs = mysql_query ( $mysqlQuery )) {
     echo "Cannot parse query";
    } elseif (mysql_num_rows ( $rs ) == 0) {
     echo "No records found";
    } else {
     echo "<table id=\"myTable\" table width=\"710\" class=\"beautifuldata\" align=\"Left\" cellspacing=\"0\">\n";
     echo "<thead>\n<tr>";
     echo "<th>PLACE</th>";
     echo "<th>ADDRESS</th>";
     echo "<th>PHONE</th>";
     echo "<th>PRICE</th>";
     echo "<th>RATING</th>";
     echo "</tr>\n</thead>\n";
     while ( $row = mysql_fetch_array ( $rs ) ) {
      echo "<tr><td><strong><a href='" . $row [RestPage] . "'>" . $row ['RestName'] . "</a></strong></td>";
      echo "<td>" . $row ['DetailName'] . "</td>";
      echo "<td>" . $row ['Phone'] . "</td>";
      echo "<td>" . $row ['Price'] . "</td>";
      echo "<td>" . $row ['Rating'] . "</td>";
      echo "</tr>";
     }
    }
    echo "</table><br />\n";
    
    mysql_close ( $con );
    }
    ?>
    </p>
    <p> </p>
    <p> </p>
    <p>  </p>
    <form method="post" name="Critters" id="Critters">
     <div align="left">
    <table width="950" border="0" cellspacing="0" cellpadding="0">
    <tbody>
     <tr>
      <th class="tblHead" width="11" scope="col"> </th>
      <th class="tblHead" width="19" scope="col"> </th>
      <th class="tblHead" width="195" scope="col">FEATURES</th>
      <th class="tblHead" width="206" scope="col">MEAL PERIODS</th>
      <th class="tblHead" width="215" scope="col">SERVICES</th>
      <th class="tblHead" width="268" scope="col">TYPE OF PLACE</th>
      <th class="tblHead" width="51" scope="col"> </th>
     </tr>
     <tr>
      <td> </td>
      <td> </td>
      <td><strong> <input name="criteria[]" type="checkbox" id="Buffet"
       value="Buffet"> <label for="Buffet"> Buffet</label> </strong></td>
      <td><strong> <input name="criteria[]" type="checkbox" id="Breakfast"
       value="Breakfast"> <label for="Breakfast"> Breakfast</label> </strong>
      </td>
      <td><strong> <input name="criteria[]" type="checkbox" id="BYOB"
       value="BYOB"> <label for="BYOB"> BYOB</label> </strong></td>
      <td><strong> <input name="criteria[]" type="checkbox" id="Bar Scene"
       value="Bar Scene"> <label for="Bar Scene"> Bar Scene</label> </strong>
      </td>
      <td> </td>
     </tr>
     <tr>
      <td> </td>
      <td> </td>
      <td><strong> <input name="criteria[]" type="checkbox" id="Fireplace"
       value="Fireplace"> <label for="Fireplace"> Fireplace</label> </strong>
      </td>
      <td><strong> <input name="criteria[]" type="checkbox" id="Brunch"
       value="Brunch"> <label for="Brunch"> Brunch</label> </strong></td>
      <td><strong> <input name="criteria[]" type="checkbox" id="Catering"
       value="Cateringt"> <label for="Catering"> Catering</label> </strong>
      </td>
      <td><strong> <input name="criteria[]" type="checkbox"
       id="Business Dining" value="Business Dining"> <label
       for="Business Dining"> Business Dining</label> </strong></td>
      <td> </td>
     </tr>
     <tr>
      <td> </td>
      <td> </td>
      <td><strong> <input name="criteria[]" type="checkbox"
       id="Great Views" value="Great Views"> <label for="Great Views">
      Great Views</label> </strong></td>
      <td><strong> <input name="criteria[]" type="checkbox" id="Dinner"
       value="Dinner"> <label for="Dinner"> Dinner</label> </strong></td>
      <td><strong> <input name="criteria[]" type="checkbox"
       id="Credit Cards" value="Credit Cards"> <label for="Credit Cards">
      Credit Cards</label> </strong></td>
      <td><strong> <input name="criteria[]" type="checkbox" id="Cheap Eats"
       value="Cheap Eats"> <label for="Cheap Eats"> Cheap Eats</label> </strong>
      </td>
      <td> </td>
     </tr>
     <tr>
      <td> </td>
      <td> </td>
      <td><strong> <input name="criteria[]" type="checkbox"
       id="Outdoor Dining" value="Outdoor Dining"> <label
       for="Outdoor Dining"> Outdoor Dining</label> </strong></td>
      <td><strong> <input name="criteria[]" type="checkbox" id="Happy Hour"
       value="Happy Hour"> <label for="Happy Hour"> Happy Hour</label> </strong>
      </td>
      <td><strong> <input name="criteria[]" type="checkbox" id="Delivery"
       value="Delivery"> <label for="Delivery"> Delivery</label> </strong>
      </td>
      <td><strong> <input name="criteria[]" type="checkbox" id="Diner"
       value="Diner"> <label for="Diner"> Diner</label> </strong></td>
      <td> </td>
     </tr>
     <tr>
      <td> </td>
      <td> </td>
      <td><strong> <input name="criteria[]" type="checkbox"
       id="Private Room(s)" value="Private Room(s)"> <label
       for="Private Room(s)"> Private Room(s)</label> </strong></td>
      <td><strong> <input name="criteria[]" type="checkbox" id="Late Night"
       value="Late Night"> <label for="Late Night"> Late Night</label> </strong>
      </td>
      <td><strong> <input name="criteria[]" type="checkbox"
       id="Food Truck / Cart" value="Food Truck / Cart"> <label
       for="Food Truck / Cart"> Food Truck / Cart</label> </strong></td>
      <td><strong> <input name="criteria[]" type="checkbox" id="Gastro-Pub"
       value="Gastro-Pub"> <label for="Gastro-Pub"> Gastro-Pub</label> </strong>
      </td>
      <td> </td>
     </tr>
     <tr>
      <td> </td>
      <td> </td>
      <td><strong> <input name="criteria[]" type="checkbox" id="Raw Bar"
       value="Raw Bar"> <label for="Raw Bar"> Raw Bar</label> </strong></td>
      <td><strong> <input name="criteria[]" type="checkbox" id="Lunch"
       value="Lunch"> <label for="Lunch"> Lunch</label> </strong></td>
      <td><strong> <input name="criteria[]" type="checkbox"
       id="On-Line Ordering" value="On-Line Ordering"> <label
       for="On-line Ordering"> On-Line Ordering</label> </strong></td>
      <td><strong> <input name="criteria[]" type="checkbox"
       id="Group Dining" value="Group Dining"> <label for="Group Dining">
      Group Dining</label> </strong></td>
      <td> </td>
     </tr>
     <tr>
      <td> </td>
      <td> </td>
      <td><strong> <input name="criteria[]" type="checkbox" id="Waterfront"
       value="Waterfront"> <label for="Waterfront"> Waterfront</label> </strong>
      </td>
      <td><strong> <input name="criteria[]" type="checkbox"
       id="Open 24 Hours" value="Open 24 Hours"> <label for="Open 24 Hours">
      Open 24 Hours</label> </strong></td>
      <td><strong> <input name="criteria[]" type="checkbox"
       id="On-Line Reservations" value="On-Line Reservations"> <label
       for="On-line Reservations"> On-line Reservations</label> </strong></td>
      <td><strong> <input name="criteria[]" type="checkbox"
       id="Hotel Dining" value="Hotel Dining"> <label for="Hotel Dining">
      Hotel Dining</label> </strong></td>
      <td> </td>
     </tr>
     <tr>
      <td> </td>
      <td> </td>
      <td><strong> <input name="criteria[]" type="checkbox"
       id="Wheelchair Access" value="Wheelchair Access"> <label
       for="Wheelchair Access"> Wheelchair Access</label> </strong></td>
      <td><strong> <input name="criteria[]" type="checkbox"
       id="Pre / Post Theatre" value="Pre / Post Theatre"> <label
       for="Pre / Post Theatre"> Pre / Post Theatre</label> </strong></td>
      <td><strong> <input name="criteria[]" type="checkbox"
       id="Reservations" value="Reservations"> <label for="Reservations">
      Reservations</label> </strong></td>
      <td><strong> <input name="criteria[]" type="checkbox"
       id="Kid Friendly" value="Kid Friendly"> <label for="Kid Friendly">
      Kid Friendly</label> </strong></td>
      <td> </td>
     </tr>
     <tr>
      <td> </td>
      <td> </td>
      <td><strong> <input name="criteria[]" type="checkbox" id="Wi-Fi"
       value="Wi-Fi"> <label for="Wi-Fi"> Wi-Fi</label> </strong></td>
      <td> </td>
      <td><strong> <input name="criteria[]" type="checkbox" id="Take-Out"
       value="Take-Out"> <label for="Take-Out"> Take-Out</label> </strong>
      </td>
      <td><strong> <input name="criteria[]" type="checkbox"
       id="Live Entertainment" value="Live Entertainment"> <label
       for="Live Entertainment"> Live Entertainment</label> </strong></td>
      <td> </td>
     </tr>
     <tr>
      <td> </td>
      <td> </td>
      <td> </td>
      <td> </td>
      <td><strong> <input name="criteria[]" type="checkbox"
       id="Text Ordering" value="Text Ordering"> <label for="Text Ordering">
      Text Ordering</label> </strong></td>
      <td><strong> <input name="criteria[]" type="checkbox"
       id="People Watching" value="People Watching"> <label
       for="People Watching"> People Watching</label> </strong></td>
      <td> </td>
     </tr>
     <tr>
      <td> </td>
      <td> </td>
      <td> </td>
      <td> </td>
      <td> </td>
      <td><strong> <input name="criteria[]" type="checkbox" id="Romantic"
       value="Romantic"> <label for="Romantic"> Romantic</label> </strong>
      </td>
      <td> </td>
     </tr>
     <tr>
      <td> </td>
      <td> </td>
      <td> </td>
      <td> </td>
      <td> </td>
      <td><strong> <input name="criteria[]" type="checkbox" id="Specials"
       value="Specials"> <label for="Specials"> Specials</label> </strong>
      </td>
      <td> </td>
     </tr>
     <tr>
      <td> </td>
      <td> </td>
      <td> </td>
      <td> </td>
      <td> </td>
      <td><strong> <input name="criteria[]" type="checkbox" id="Sports Bar"
       value="Sports Bar"> <label for="Sports Bar"> Sports Bar</label> </strong>
      </td>
      <td> </td>
     </tr>
     <tr>
      <td> </td>
      <td> </td>
      <td> </td>
      <td> </td>
      <td> </td>
      <td><strong> <input name="criteria[]" type="checkbox"
       id="Tasting Menu" value="Tasting Menu"> <label for="Tasting Menu">
      Tasting Menu</label> </strong></td>
      <td> </td>
     </tr>
     <tr>
      <td> </td>
      <td> </td>
      <td> </td>
      <td> </td>
      <td> </td>
      <td><strong> <input name="criteria[]" type="checkbox" id="Theme"
       value="Theme"> <label for="Theme"> Theme</label> </strong></td>
      <td> </td>
     </tr>
     <tr>
      <td> </td>
      <td> </td>
      <td> </td>
      <td> </td>
      <td> </td>
      <td><strong> <input name="criteria[]" type="checkbox" id="Trendy"
       value="Trendy"> <label for="Trendy"> Trendy</label> </strong></td>
      <td> </td>
     </tr>
    </tbody>
    </table>
    </div>
    <p><input type="submit" name="btnSearch" id="btnSearch"
    value="		  SEARCH		  "></p>
    </form>
    </body>
    </html>
    

  19. Barand, Not to much to ask at all, but if one does not know, because one is new, then, well you understand, kicken and Barand. I found the problem. It's this. I am running a condition on a table that can only possibly give me one answer. tblDetails. I have to run it from the tblLocDet that contains all of the records of the details as well as the locations. I am testing it now and will return. Thank you both for your help.

×
×
  • 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.