Advertisement
SouldrinK

Untitled

Oct 29th, 2012
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. include("config.php");
  3.  
  4. function unhide($id, $counter) {
  5.     mysql_query("UPDATE tours SET Hide='0' WHERE Id = '" . $id . "' LIMIT 1");
  6.     echo $counter . ". " . $id . "<br>\n";
  7. }
  8.  
  9. if (isset($_GET['companyId']) && is_numeric($_GET['companyId'])) {
  10.    
  11.     $companyId = $_GET['companyId'];
  12.  
  13.     $query = "SELECT tours.Id, tours.Name FROM tours JOIN dates ON tours.Id = dates.TourId AND dates.StartDate > '2012-12-31' WHERE Hide = '1' AND tours.CompanyId = '" . $companyId . "' ORDER BY tours.Id";
  14.     $result = mysql_query($query);
  15.    
  16.     $oldid = 0;
  17.     $counter = 0;
  18.     if (mysql_num_rows($result) > 0) {
  19.         while ($row = mysql_fetch_array($result)) {
  20.             if ($row['Id'] != $oldid) {
  21.                 $counter++;
  22.                 //echo $row['Id'] . "<br>\n";
  23.                 unhide($row['Id'], $counter);
  24.                 $oldid = $row['Id'];
  25.             }
  26.         }
  27.     } else {
  28.         echo "No tours found that meet criteria.";
  29.     }
  30.  
  31. } else {
  32.     echo "we need a companyId.";
  33.     exit();
  34. }
  35. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement