Mogge,
Ik heb een bestaande search die hieronder gepost staat. Nou wil ik alleen een waarde toevoegen bij de search. Dat moet zijn dat je 'rates' onder een bepaald bedrag kan selecteren. Hieronder heb ik eerst de searchbox gepost en daaronder waar hij hem heenstuurt ('calculate.inc'). Misschien kan iemand mij hierbij helpen, ik wil dus eigenlijk een extra select box waarbij je onder 3 of 4 prijzen kan selecteren.
Waar voor mij ook een beetje het probleem ligt is dat hij de rates opslaat als een complete string, en $rates haalt die uit elkaar maar kom daar dus niet echt verder.
alvast bedankt!
search output page met searchbox
<script language="JavaScript">
function popUp(URL, w, h) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width="+w+",height="+h+",left = 0,top = 0');");
}
</script>
<center><?php
function getmicrotime(){
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
// calculate execution time
$time_start = getmicrotime();
echo "<table><tr><td>";
echo boxStart2("Find available hotels");
?><form action="/search/" method=get>
<table align="center" cellpadding=2 cellspacing=2 border=0>
<tr>
<td>Arrival</td>
<td>
<?php
$tomorrow = mktime (0,0,0,date("m") ,date("d")+1,date("Y"));
$today_day = date("j",$tomorrow);
$today_month = date("n",$tomorrow);
$today_year = date("Y",$tomorrow);
echo '<select name="arrD" class="text">\n';
for ($i=1;$i<32;$i++) {
if ($saveArrD != "") {
$selected = ($saveArrD == $i) ? " selected" : "";
}
else {
$selected = ($today_day == $i) ? " selected" : "";
}
echo "<option value=$i$selected>$i</option>\n";
}
echo '</select>';
?>
<?php
echo '<select name="arrM" class="text">\n';
for ($i=1;$i<13;$i++) {
$tempMonth = mktime (0,0,0,$i,1,2005);
if ($saveArrM != "") {
$selected = ($saveArrM == date("n",$tempMonth)) ? " selected" : "";
}
else {
$selected = ($today_month == date("n",$tempMonth)) ? " selected" : "";
}
$month = date("F",$tempMonth);
$monthdigit = date("n",$tempMonth);
echo "<option value=$monthdigit$selected>$month </option>\n";
}
echo '</select>';
?>
<?php
echo '<select name="arrY" class="text">\n';
$year = date("Y");
$year2 = date("Y")+1;
echo "<option value=$year>$year</option>\n";
echo "<option value=$year2>$year2</option>\n";
echo '</select>';
?>
</td>
</tr>
<tr>
<td>Departure</td>
<td>
<?php
$tomorrow = mktime (0,0,0,date("m") ,date("d")+2,date("Y"));
$next_day = date("j",$tomorrow);
$next_month = date("n",$tomorrow);
$next_year = date("Y",$tomorrow);
echo '<select name="depD" class="text">\n';
for ($i=1;$i<32;$i++) {
if ($saveDepD != "") {
$selected = ($saveDepD == $i) ? " selected" : "";
}
else {
$selected = ($next_day == $i) ? " selected" : "";
}
echo "<option value=$i$selected>$i</option>\n";
}
echo '</select>';
?>
<?php
echo '<select name="depM" class="text">\n';
for ($i=1;$i<13;$i++) {
$tempMonth = mktime (0,0,0,$i,1,2005);
if ($saveDepM != "") {
$selected = ($saveDepM == date("n",$tempMonth)) ? " selected" : "";
}
else {
$selected = ($next_month == date("n",$tempMonth)) ? " selected" : "";
}
$month = date("F",$tempMonth);
$monthdigit = date("n",$tempMonth);
echo "<option value=$monthdigit$selected>$month</option>\n";
}
echo '</select>';
?>
<?php
echo '<select name="depY" class="text">\n';
$year = date("Y");
$year2 = date("Y")+1;
echo "<option value=$year>$year</option>\n";
echo "<option value=$year2>$year2</option>\n";
echo '</select>';
?>
</td>
</tr>
<tr>
<td></td>
<td colspan=2><input type="submit" value="check availability" class="button"></td>
</tr></form>
</table></center>
<?php
echo $end_table2;
if ($arrD && $arrM && $arrY && $depD && $depM && $depY) {
echo "</td><td>";
include("calculate.inc");
echo boxStart("Booking details");
echo "
<table>
<tr>
<td><b>arrival</b></td>
<td>$txt_arrival</td>
</tr>
<tr>
<td><b>departure</b></td>
<td>$txt_departure</td>
</tr>
<tr>
<td><b>nights</b></td>
<td>$nights</td>
</tr>
</table>
";
echo $end_table;
echo "</td></tr></table>";
echo "<div align=center>
show only:<br>
<a href=\"/search/?aid=$aid&city=Amsterdam&hotel_class=1&arrD=$arrD&arrM=$arrM&arrY=$arrY&depD=$depD&depM=$depM&depY=$depY\"><b>1star hotels</b></a> |
<a href=\"/search/?aid=$aid&city=Amsterdam&hotel_class=2&arrD=$arrD&arrM=$arrM&arrY=$arrY&depD=$depD&depM=$depM&depY=$depY\"><b>2star hotels</b></a> |
<a href=\"/search/?aid=$aid&city=Amsterdam&hotel_class=3&arrD=$arrD&arrM=$arrM&arrY=$arrY&depD=$depD&depM=$depM&depY=$depY\"><b>3star hotels</b></a> |
<a href=\"/search/?aid=$aid&city=Amsterdam&hotel_class=4&arrD=$arrD&arrM=$arrM&arrY=$arrY&depD=$depD&depM=$depM&depY=$depY\"><b>4star hotels</b></a> |
<a href=\"/search/?aid=$aid&city=Amsterdam&hotel_class=5&arrD=$arrD&arrM=$arrM&arrY=$arrY&depD=$depD&depM=$depM&depY=$depY\"><b>5star hotels</b></a> |
<a href=\"/search/?aid=$aid&city=Amsterdam&hotel_class=6&arrD=$arrD&arrM=$arrM&arrY=$arrY&depD=$depD&depM=$depM&depY=$depY\"><b>Bed and Breakfasts</b></a>
</div><br>
";
$template["searchresult"] = "
";
//echo "<a href='#' onclick=\"debug.style.display='inline';return false;\"> debug</a><div id=debug style='display:none'><pre>$sql</pre></div><br><br>";
$realfree = 999;
while($r = mysql_fetch_object($res)) {
$map_url = "http://tools.locatienet.com/location/map.asp?config_id=5012&zipcode=$r->zipcode&country=NL&zoom=3&language=english&markertext=".rawurlencode($r->hotelname);
$confirmationtype = ($r->instant == 1) ? "<img src=\"/images/instant.gif\">" : "<img src=\"/images/onrequest.gif\">";
$style = "bgcolor=\"#FFD19A\" style='border-bottom:1px solid #7C4606;color: #7C4606'";
$style2 = "style='color:#7C4606'";
$style3 = "style='border:2px solid #EFCDA4'";
if ($lastHotel != $r->hotelname) {
echo $not_first;
$count++;
echo boxStart2("$count. <a href=\"/amsterdam/$r->shortname/\" class=white><b>$r->hotelname</b></a>");
echo "<table border=0 cellpadding=2 cellspacing=0>";
$colspan = $nights+1;
echo "<tr><td align=center><img src=\"/images/hotels/$r->hid.jpg\" width=64 height=64 $style3></td>
<td valign=top colspan=4><img src=\"/images/$r->stars"."stars.gif\" width=70 height=14>
$confirmationtype
<br>
<b>Location:</b> <a href=\"javascript:popUp('$map_url',625,400)\">$r->area</a>
</tr>
<tr><td align=center $style><b $style2>roomtype</b></td><td align=left $style><b>available</b></td>\n";
for ($i=1;$i<($nights+1);$i++) {
$shrt_date = date("d M",mktime(0,0,0,$arrM,$arrD+$i-1,$arrY));
echo "<td width=45 $style>$shrt_date <img src=\"/images/list.gif\" width=5 vspace=1></td>\n";
}
echo "<td $style><b>total</b></td><td $style> </td>\n";
}
// check available rooms
for ($i=1;$i<$nights+1;$i++) {
eval ("\$realfree = (\$r->free$i < \$realfree) ? \$r->free$i : \$realfree;");
}
echo "</tr><tr><td align=center width=120>$r->roomtype</td><td width=80 align=left><b style='color:green'>$realfree rooms</b></td>\n";
$realfree = 999;
// display rates per day
for ($i=1;$i<$nights+1;$i++) {
echo "<td>€ ";
eval ("echo \$r->rate$i*1;");
echo "</td>\n";
}
echo "<td><b>€ $r->total_rate</b></td><td><a href=\"/amsterdam/$r->shortname/?aid=$saveArrD&arrM=$saveArrM&arrY=$saveArrY&depD=$saveDepD&depM=$saveDepM&depY=$saveDepY\"><b>book now</a></a></td></tr>\n";
$lastHotel = $r->hotelname;
$not_first = "</table>$end_table2";
}
echo $not_first;
}
else {
echo "</table>";
}
$time_end = getmicrotime();
$time = $time_end - $time_start;
echo "<script>window.status = $time;</script>";
?>
calculate.inc
<?php
$arrival = mktime (0,0,0,$arrM ,$arrD,2004);
$departure = mktime (0,0,0,$depM ,$depD,2004);
$txt_arrival = date("D j M Y", mktime (0,0,0,$arrM ,$arrD,$arrY));
$txt_departure = date("D j M Y", mktime (0,0,0,$depM ,$depD,$depY));
$arrival = date("z",$arrival) + 1;
$departure = date("z",$departure) + 1;
$startYear = 2005;
$yearDifference1 = $arrY - $startYear;
$yearDifference2 = $depY - $startYear;
// init values
$start_day = $arrival + ($yearDifference1 * 366);
$end_day = $departure + ($yearDifference2 * 366);
// calculate nights
$nights = $end_day - $start_day;
if ($nights > 30) {
die("You cannot book more than 30 nights");
}
$pos_start = 1 + ($start_day - 1) * 3;
$pos2_start = 1 + ($start_day - 1) * 2;
$xxs = date("w", mktime (0,0,0,$arrM,$arrD,$currentYear));
for ($i=1;$i < $nights + 1;$i++) {
$pos = ($i - 1) * 3;
$pos = $pos_start + $pos;
$pos2 = ($i - 1) * 2;
$pos2 = $pos2_start + $pos2;
$pointx = $arrival-1+$i;
if ($pointx == 60 && !date("L",mktime(0,0,0,1,1,$arrY))) {
$leapyear = 1;
}
else {
$leaper++;
$count_price .= "substring(t1.rates,$pos,3) +\n";
$seek_available .="substring(t1.free,$pos2,2) > 0 and\n";
$rates .= "substring(t1.rates,$pos,3) as rate$leaper,";
$free .= "substring(t1.free,$pos2,2) * 1 as free$leaper,";
}
}
$nights = $nights - $leapyear;
$hotel_class = ($hotel_class == 0) ? "" : "and t2.stars='$hotel_class'";
$sql = "
select
t1.id as rid,
t2.id as hid,
t1.*,
t2.*,
$free
$count_price 0 as total_rate
from
rooms as t1,
hotels as t2
where
t1.hotel = t2.id
and
t1.active = 1
and
t2.active = 1
and
($count_price 0) > 10
and
substring(t1.minstays,$start_day,1) <= $nights
and
$seek_available 1
$hotel_class
$rates
order by t2.instant desc,t2.priority desc,t2.id
";
$res = mysql_query($sql);
?>
797 views