날자가 뒤죽박죽 되어서 이거 날자 정렬 관련 채택완료

f_datestr 에 날자가 정렬이 맞지 않아서 이거 정렬을 하려면 어떻게 처리를 해야 할까요 

2049131254_1701847062.4501.png

혹시 몰라서 소스 올려 드립니다

Copy
<?php

$daesu = htmlentities($daesu);
//$fcode = htmlentities($fcode);
$nowpage = htmlentities($nowpage);
$totalpage = htmlentities($totalpage);
$c_code = htmlentities($c_code);
$mode = htmlentities($mode);
$cont = htmlentities($cont);

if($cont != "yes") {
   $totalrec = 0;

   $qry = "select f_name1 from tbl_speaker where  f_mcode = '".$c_code."'";

   $rs = @mysql_query($qry);
   if(!$rs) {
        print("<br /><br /><center>발언자를 검색하는 중에 에러가 발생했습니다(1).</center>");
    }
   $totalrec = @mysql_num_rows($rs);
}  /* end of nextpage */

if($totalrec > 0) {
   if(!$nowpage) {
        $nowpage = 1;
    }

    $totalpage = ceil($totalrec / 10);
    $blockpage = floor(($nowpage - 1) / 10) +1;
    
    $startpage = ($blockpage - 1) * 10 + 1;
    $endpage = $blockpage * 10;

    if($totalpage < $endpage) {
        $endpage = $totalpage;
    }

    $firstrec = ($nowpage - 1) * 10;
    $cnt = $totalrec - $firstrec;
    if($cnt > 10) {
        $cnt = 10;
    }

  $i = $firstrec;
  $qry = "select * from tbl_speaker where  f_mcode = '".$f_code."' order by f_th desc,f_code asc,f_cha asc limit ".$firstrec.", ".$cnt;
  $rs = mysql_query($qry);
  if(!$rs) {
      print("<br /><br /><center>발언자를 검색하는 중에 에러가 발생했습니다(2).</center>");
  }

    while($row = mysql_fetch_array($rs)) {
        $no = $totalrec - $i;
        $i++;

        $mname = urlencode($row[f_name1]."-".$row[f_name2]);

        $row[f_etc1] = str_replace("유성구의회", "", $row[f_etc1]);


        // 2019-09-26 js
        if($row[f_cha] == 0 || $row[f_cha] == 99) {
            $f_th = "제".$row[f_th]."회";
        }
        else {
            if(strchr($row[f_code], "H")) {
                $f_th = $row[f_th]."년도 행정사무감사";
            }
            else {
                $f_th = "제".$row[f_th]."회";
            }
        }


        $strTh = $f_th." ".$row[f_chastr]." ".$row[f_etc1]."(".$row[f_datestr].")";

        $qryan = "select * from tbl_angun where f_file = '".$row[f_file]."' order by f_angunno asc";
        $rsan = mysql_query($qryan);
        if(!$rsan) {
        print "<br /><br /><br /><center><b>데이타를 검색하는 중에 에러가 발생했습니다(5).</b></center>";
        }

    ?>

    <tr>
    <td scope="row" class="no"><?=$no--;?>.</td>
    <td class="con"> <a href="/CLRecords/Retrieval2/index.php?hfile=<?=$row[f_file];?>&amp;daesu=<?=$row[f_daesu];?>&amp;mname=<?=$mname;?>&amp;mode=speaker1#w1" onclick="window.open(this.href, 'late', 'scrollbars=yes,width=1024,height=768'); return false;" title="<?=$strTh;?>(새창)"><?=$strTh;?></a></td>
    </tr>

     <? } ?>

<? } ?>

답변 2개

채택된 답변
+20 포인트

$qry = "select * from tbl_speaker where  f_mcode = '".$f_code."' order by f_th desc,f_code asc,f_cha asc limit ".$firstrec.", ".$cnt;

$qry = "select * from tbl_speaker where  f_mcode = '".$f_code."' order by f_datestr asc, f_th desc,f_code asc,f_cha asc limit ".$firstrec.", ".$cnt;

로그인 후 평가할 수 있습니다

답변에 대한 댓글 3개

답변 감사 드립니다.
이게 최근 날짜가 제일 위로 올라와야 하는데 맨 뒤로 가서요 이건 어떻게
f_datestr desc
역시 천제시네요 감사합니다

댓글을 작성하려면 로그인이 필요합니다.

요일 필드를 추가해서 분리하시는 걸 추천해 드립니다.

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인
🐛 버그신고