|
|
|
ทำ function ajax load content แล้ว content ออกมาไม่ครบครับ |
|
|
|
|
|
|
|
Code (JavaScript)
<script>
function loadBestProducts(pt,pv,obj){
$(this).find('li').addClass('on');
$.get('content/server_bestproducts.php', {'pt':pt, 'pv': pv}, function(data){
$(obj).html(data).show();
});
}
loadBestProducts('HT', '1', '#content-hotel');
loadBestProducts('RS', '1', '#content-residence');
loadBestProducts('GF', '1', '#content-golf');
</script>
<div id="content-hotel">
</div>
<div id="content-residence">
</div>
<div id="content-golf">
</div>
content/server_bestproducts.php
Code (PHP)
<?php
require("../config/connect.php");
require("../config/function.php");
require("../config/html2text.php");
if($_REQUEST['pt'] == 'HT'){ // if Products Type = Hotel
$strSQL = "SELECT * FROM hotel WHERE province_id = '".$_REQUEST['pv']."' ORDER BY hotel_id DESC limit 0,5";
$strQuery = mysql_query($strSQL);
?>
<div id="hotel-head">
<h5><img src="images/header1.png"></h5>
<ul class="tab01">
<li <?php if($_REQUEST['pv'] == 1){ echo "class='on'"; } ?>>
<a href="javascript: loadBestProducts('HT', '1', '#content-hotel');">방콕</a>
</li>
<li <?php if($_REQUEST['pv'] == 2){ echo "class='on'"; } ?>>
<a href="javascript: loadBestProducts('HT', '2', '#content-hotel');">파타야</a>
</li>
<li class="none <?php if($_REQUEST['pv'] == 3){ echo "on"; } ?>">
<a href="javascript: loadBestProducts('HT', '3', '#content-hotel');">치앙마이</a>
</li>
</ul>
</div>
<div id="show-hotel">
<?
while ($strResult = mysql_fetch_array($strQuery)){
$minHotel = mysql_query("SELECT min(bedroom_price) FROM room_bedroom_price WHERE products_code = '".$strResult['products_code']."' ")or die(mysql_error());
$minHotelR = mysql_fetch_array($minHotel);
$imgSQL = "SELECT * FROM images WHERE products_code = '$strResult[products_code]'";
$imgQuery = mysql_query($imgSQL);
$imgResult = mysql_fetch_array($imgQuery);
$hotel_detail = html2text($strResult['hotel_detail']);
?>
<div id="hotel">
<a href="?page=view_hotel&pidx=<?=$strResult['products_code']; ?>"><img src="images/hotel_images/<?=$imgResult['images_name']; ?>"></a>
<div id="hotel-home-detail"><?=$strResult['hotel_name_kr']; ?></div>
<p class="txt01 pt5"><?=mb_substr($hotel_detail,0,35,'UTF-8'); ?> ...</p>
<p class="txt02 mt15"><strong class="f_red"><?=number_format(getCurrency($minHotelR['min(bedroom_price)']), 0) ?>원</strong> (<?=number_format($minHotelR['min(bedroom_price)'], 0); ?> 바트)</p>
</div>
<?php
}
?> </div> <?php
} else if($_REQUEST['pt'] == 'RS'){ //if Products Type = Residence
$resStrSQL = "SELECT * FROM resident WHERE province_id = '".$_REQUEST['pv']."' ORDER BY resident_id DESC limit 0,5";
$resStrQuery = mysql_query($resStrSQL);
?>
<div id="hotel-head">
<h5><img src="images/header3.png"></h5>
<ul class="tab01">
<li <?php if($_REQUEST['pv'] == 1){ echo "class='on'"; } ?>>
<a href="javascript: loadBestProducts('RS', '1', '#content-residence');">방콕</a>
</li>
<li <?php if($_REQUEST['pv'] == 2){ echo "class='on'"; } ?>>
<a href="javascript: loadBestProducts('RS', '2', '#content-residence');">파타야</a>
</li>
<li class="none <?php if($_REQUEST['pv'] == 3){ echo "on"; } ?>">
<a href="javascript: loadBestProducts('RS', '3', '#content-residence');">치앙마이</a>
</li>
</ul>
</div>
<div id="show-residence">
<?php
while ($resStrResult = mysql_fetch_array($resStrQuery)){
$minRes = mysql_query("SELECT min(bedroom_price) FROM room_bedroom_price WHERE products_code = '".$resStrResult['products_code']."' ")or die(mysql_error());
$minResR = mysql_fetch_array($minRes);
$imgSQL = "SELECT * FROM images WHERE products_code = '$resStrResult[products_code]'";
$imgQuery = mysql_query($imgSQL);
$imgResult = mysql_fetch_array($imgQuery);
$res_detail = html2text($resStrResult['resident_detail']);
?>
<div id="hotel">
<a href="?page=view_residence&pidx=<?=$resStrResult['products_code']; ?>&m=h"><img src="images/hotel_images/<?=$imgResult['images_name']; ?>"></a>
<div id="hotel-home-detail"><?=$resStrResult['resident_name_kr']; ?></div>
<p class="txt01 pt5"><?=mb_substr($res_detail,0,35,'UTF-8'); ?> ...</p>
<p class="txt02 mt15"><strong class="f_red"><?=number_format(getCurrency($minResR['min(bedroom_price)']), 0) ?>원</strong> (<?=number_format($minResR['min(bedroom_price)'], 0); ?> 바트)</p>
</div>
<?php
}
?> </div> <?php
} else if ($_REQUEST['pt'] == 'GF'){ //if Products Type = Golf
$golfStrSQL = "SELECT * FROM golf WHERE province_id = '".$_REQUEST['pv']."' ORDER BY golf_id DESC limit 0,5";
$golfStrQuery = mysql_query($golfStrSQL);
?>
<div id="hotel-head">
<h5><img src="images/header2.png"></h5>
<ul class="tab01">
<li <?php if($_REQUEST['pv'] == 1){ echo "class='on'"; } ?>>
<a href="javascript: loadBestProducts('GF', '1', '#content-golf');">방콕</a>
</li>
<li <?php if($_REQUEST['pv'] == 2){ echo "class='on'"; } ?>>
<a href="javascript: loadBestProducts('GF', '2', '#content-golf');">파타야</a>
</li>
<li class="none <?php if($_REQUEST['pv'] == 3){ echo "on"; } ?>">
<a href="javascript: loadBestProducts('GF', '3', '#content-golf');">치앙마이</a>
</li>
</ul>
</div>
<div id="show-golf">
<?php
while ($golfStrResult = mysql_fetch_array($golfStrQuery)){
$minGolf = mysql_query("SELECT min(weekday_day_price) FROM golf_price WHERE products_code = '".$golfStrResult['products_code']."' ")or die(mysql_error());
$minGolfR = mysql_fetch_array($minGolf);
$imgSQL = "SELECT * FROM images WHERE products_code = '$golfStrResult[products_code]'";
$imgQuery = mysql_query($imgSQL);
$imgResult = mysql_fetch_array($imgQuery);
$golf_detail = html2text($golfStrResult['golf_information']);
?>
<div id="hotel">
<a href="?page=view_golf&pidx=<?=$golfStrResult['products_code']; ?>"><img src="images/golf_images/<?=$imgResult['images_name']; ?>"></a>
<div id="hotel-home-detail"><?=$golfStrResult['golf_name_kr']; ?></div>
<p class="txt01 pt5"><?=mb_substr($golf_detail,0,35,'UTF-8'); ?> ...</p>
<p class="txt02 mt15"><strong class="f_red"><?=number_format(getCurrency($minGolfR['min(weekday_day_price)']), 0) ?>원</strong> (<?=number_format($minGolfR['min(weekday_day_price)'], 0); ?> 바트)</p>
</div>
<?php
}
?> </div> <?php
}
?>
โปรแกรมมันโชว์ แค่ content ของ โรงแรมครับ ไม่แสดงส่วนของอีก 2 content ที่เรียก
Tag : PHP, HTML/CSS, JavaScript, jQuery
|
|
|
|
|
|
Date :
2012-12-17 10:49:59 |
By :
Necrotorture |
View :
1035 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
บรรทัดข้างล่างนี้ตัว $(this) อ้างอิง element ตัวไหนและจากที่ไหนครับ?
Code (JavaScript)
$(this).find('li').addClass('on');
|
|
|
|
|
Date :
2012-12-17 14:48:38 |
By :
dreamlover |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
แก้ได้แล้วครับ พอดีผมใช้ div content-hotel คลุม ทั้ง 3 div มันเลยแสดงผลแค่ อันเดียว อิอิ
|
|
|
|
|
Date :
2012-12-17 15:01:57 |
By :
Necrotorture |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|