<?php require_once('Connections/conn_newland.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

mysql_select_db($database_conn_newland, $conn_newland);
$query_rs_worldregions = "SELECT regionID, regionName FROM tbl_region ORDER BY regionName ASC";
$rs_worldregions = mysql_query($query_rs_worldregions, $conn_newland) or die(mysql_error());
$row_rs_worldregions = mysql_fetch_assoc($rs_worldregions);
$totalRows_rs_worldregions = mysql_num_rows($rs_worldregions);

mysql_select_db($database_conn_newland, $conn_newland);
$query_rs_countries = "SELECT countryID, countryName FROM tbl_country WHERE EXISTS(SELECT tourID FROM tbl_tours WHERE tbl_tours.country = tbl_country.countryID) ORDER BY countryName ASC";
$rs_countries = mysql_query($query_rs_countries, $conn_newland) or die(mysql_error());
$row_rs_countries = mysql_fetch_assoc($rs_countries);
$totalRows_rs_countries = mysql_num_rows($rs_countries);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Newland Tours: Znajdź wyjazd</title>
<link href="css/main.css" rel="stylesheet" type="text/css" />
</head>

<body class="oneColFixCtrHdr">
<a href="#top"><img src="images/spacer.gif" alt="Przejdź do głównej treści strony" border="0" /></a>
<div id="container">
  <div id="header">
    <img src="images/banner_left.gif" width="451" height="68" alt="Banner Newland Tours, strona lewa." /><img src="images/banner_right.jpg" width="276" height="68" id="bannerRight" alt="Banner Newland Tours, strona prawa" />
  <!-- end #header --></div>
  <div id="navigation">
  	<ul>
      <li><a href="index.php">Strona główna</a></li>
      <li><a href="about.php">O firmie</a></li>
      <li><a href="tours.html">Znajdź wyjazd</a></li>
      <li><a href="profiles.php">Opisy krajów</a></li>
      <li><a href="contact.php">Kontakt z nami</a></li>
    </ul>
  </div>
  <div id="mainContent">
    <h1> <a name="top" id="top"></a>Znajdź  wyjazd</h1>
    <p>Użyj tej  strony do znalezienia wyjazdu Twoich marzeń. Gdy już dokonasz wyboru, skorzystaj  z <a href="tourprice.php">kalkulatora ceny wyjazdu</a>.</p>
    <p>Newland Tours oferuje wiele  wyjazdów do różnych części świata. Aby znaleźć pożądany cel podróży, użyj  poniższej tabeli, która umożliwi Ci przeglądanie ich według docelowego rejonu  świata lub kraju albo po prostu pozwoli na wyświetlenie wszystkich.    </p>
    <table width="95%" border="1" cellspacing="0" cellpadding="3">
      <tr>
        <td width="35%">Przeglądaj  według rejonu świata</td>
        <td width="65%"><?php do { ?>
            <a href="tours_detail.php?regionID=<?php echo $row_rs_worldregions['regionID']; ?>"><?php echo $row_rs_worldregions['regionName']; ?></a><br />
            <?php } while ($row_rs_worldregions = mysql_fetch_assoc($rs_worldregions)); ?></td>
      </tr>
      <tr>
        <td>Przeglądaj według kraju</td>
        <td><form id="frm_bycountry" name="frm_bycountry" method="post" action="tours_detail.php">
          <p>
            <select name="tourCountry" id="tourCountry">
              <?php
do {  
?>
              <option value="<?php echo $row_rs_countries['countryID']?>"><?php echo $row_rs_countries['countryName']?></option>
              <?php
} while ($row_rs_countries = mysql_fetch_assoc($rs_countries));
  $rows = mysql_num_rows($rs_countries);
  if($rows > 0) {
      mysql_data_seek($rs_countries, 0);
	  $row_rs_countries = mysql_fetch_assoc($rs_countries);
  }
?>
            </select>
          </p>
          <p>
            <input type="submit" name="button" id="button" value="Wyślij" />
          </p>
        </form>
        </td>
      </tr>
      <tr>
        <td><a href="tours_detail.php">Pokaż  wszystkie wyjazdy</a></td>
        <td>&nbsp;</td>
      </tr>
    </table>
    <p>
      <!-- end #mainContent -->
      </p>
  </div>
  <div id="footer">
    <p>&copy; 2007 Newland Tours</p>
  <!-- end #footer --></div>
<!-- end #container --></div>

</body>
</html>
<?php
mysql_free_result($rs_worldregions);

mysql_free_result($rs_countries);
?>
