최신글 목록 랜덤으로 뿌려지게
본문
사이트를 운영하고 있는데
'여기는 깨끗합니다' 문구 밑에 게시물들처럼 '서울'이라는 지역안에 있는 게시물들도 올린순이 아닌 랜덤으로 뿌려지게 하고 싶은데 어떻게 하면 좋을까요...
<?php
include_once('./_common.php');
include_once(G5_PATH.'/head.php');
include_once(G5_LIB_PATH.'/thumbnail.lib.php');
?>
<div id="local_search">
<div class="local_search">
<ul>
<?php
for($i=0;$i < $rcnt;$i++){
if($wr_1==$region[$i]){
echo "<a href='/sub_list.php?wr_1=".$region[$i]."&wr_homepage=&wr_2=".$wr_2."'><li class='on'>".$region[$i]."</li></a>";
$wr_1_idx = $i;
} else {
echo "<a href='/sub_list.php?wr_1=".$region[$i]."&wr_homepage=&wr_2=".$wr_2."'><li>".$region[$i]."</li></a>";
}
}
?>
</ul>
</div>
</div>
<div id="sec03_wrap">
<table>
<?php
for($i=0;$i < $ccnt;$i++){
if($i % 7 == 0) echo "<tr>";
if($wr_2==$cate[$i][1]){
echo "<td class='on'><a href='/sub_list.php?wr_1=".$wr_1."&wr_homepage=".$wr_homepage."&wr_2=".$cate[$i][1]."'><img src='".G5_IMG_URL."/main/".$cate[$i][2]."' alt='".$cate[$i][0]."'>".$cate[$i][0]."</a></td>".PHP_EOL;
} else {
echo "<td><a href='/sub_list.php?wr_1=".$wr_1."&wr_homepage=".$wr_homepage."&wr_2=".$cate[$i][1]."'><img src='".G5_IMG_URL."/main/".$cate[$i][2]."' alt='".$cate[$i][0]."'>".$cate[$i][0]."</a></td>".PHP_EOL;
}
if($i % 7 == 6) echo "</tr>";
}
?>
</table>
</div>
<?php
if($wr_homepage){
$rsub_str = $wr_homepage;
} else {
$rsub_str = "전체";
}
if($wr_2){
$wr_2_string = " - <span style='color:green'>".get_wr_2_string($wr_2)."</span>";
}
?>
<div class="list_ti_box"><b><?php echo $wr_1;?></b><?php echo " - ".$rsub_str;?><?php echo $wr_2_string;?></div>
<?php
if($wr_1) $wr_1_w = " and wr_1 = '$wr_1' ";
$home_array = explode(",", $wr_homepage);
if($home_array[0]){$wr_homepage_w=" and wr_homepage like '%{$home_array[0]}%' ";}
if($home_array[1]){$wr_homepage_w.="and wr_homepage like '%{$home_array[1]}%' ";}
if($home_array[2]){$wr_homepage_w.=" and wr_homepage like '%{$home_array[2]}%' ";}
if($home_array[3]){$wr_homepage_w.=" and wr_homepage like '%{$home_array[3]}%' ";}
//if($wr_homepage) $wr_homepage_w = " and wr_homepage = '$wr_homepage' ";
if($wr_2) $wr_2_w = " and wr_2 like '%{$wr_2}%' ";
$sql = " select count(*) as cnt from g5_write_company where (1) $wr_1_w $wr_homepage_w $wr_2_w ";
//echo $sql;
$row = sql_fetch($sql);
$list_total = $row['cnt'];
if($list_total==0) echo "<div style='text-align:center'>목록이 없습니다.</div>";
?>
<div id="sec05_wrap"></div>
<a class="more_btn" style="margin-top:-50px" href="javascript:get_list()">더보기</a>
<script>
var start = 0;
var limit = 8;
var wr_1 = "<?php echo $wr_1;?>";
var wr_homepage = "<?php echo $wr_homepage;?>";
var wr_2 = "<?php echo $wr_2;?>";
var total = <?php echo $list_total ?>;
function get_list(){
$.post("ajax_get_list.php", {start:start, limit:limit, wr_1:wr_1, wr_homepage:wr_homepage, wr_2:wr_2}, function(obj){
$("#sec05_wrap").append(obj);
if((start+limit) >= total){
$(".more_btn").css("display","none");
} else {
start = start + limit;
}
});
}
$(document).ready(function(){
get_list();
});
</script>
<br><br><br>
<div class="m_ti_box"><img src="<?php echo G5_IMG_URL ?>/main/m_ti03.jpg" alt="신규업체영역타이틀"></div>
<div id="sec04_wrap">
<?php
$sql = " select * from g5_write_company order by wr_id desc limit 9 ";
$result = sql_query($sql);
for($i=0;$row=sql_fetch_array($result);$i++){
if($i%3==0) echo "<ul>";
$thumb = get_list_thumbnail("company", $row['wr_id'], 149, 117, false, true);
?>
<li>
<a href="/sub_view.php?bo_table=company&wr_id=<?php echo $row['wr_id']?>">
<div class="area"><?php echo $row['wr_1']?>지역</div>
<div class="img">
<p class="img_title"><?php echo cut_str($row['wr_subject'],8)?></p>
<img src="<?php echo $thumb['src'] ?>" alt="<?php echo $row['wr_subject']?>" class="pt_ab">
</div>
<div class="text_box">
<div class="ti"><?php echo cut_str($row['wr_subject'],8)?></div>
<?php echo cut_str(get_wr_2_string($row['wr_2']),20);?>
<p><?php echo $row['wr_8']?></p>
</div>
</a>
</li>
<?php
if($i%3==2) echo "</ul>";
}
if($i%3!=2) echo "</ul>";
?>
</div>
<?php
include_once(G5_PATH.'/tail.php');
?>
답변 2
대략보니 ajax_get_list.php 파일 부분에서
목록을 출력하는 듯한데
전달 받은 값이 서울이라면 쿼리문을 수정해서 랜덤으로 뿌려주게
ajax_get_list.php 파일을 수정하시면 될듯합니다.
해당 리스트 가져오는 부분에서 쿼리 부분에 where 절에 order by rand() 로 추가해 가져오시면 됩니다.
답변을 작성하시기 전에 로그인 해주세요.