리스트 번호 정렬 도와주세요 > 그누4 질문답변

그누4 질문답변

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기
기존 게시물은 열람만 가능합니다.

리스트 번호 정렬 도와주세요 정보

리스트 번호 정렬 도와주세요

본문

본문번호를 번호순으로 뿌리려고 시도하는 도중에 페이지로 넘기면 정렬이 제대로 안되더군요 도와주세요

제가 하고자하는게

번호를

5
4
3
2
1 이런식으로 출력하고 싶습니다 페이지를 넘겨도 계속 유지되게요


///////////목록출력시작/////////

//변수초기화
$ipp=10;// 한페이지에 표시될 레코드 수 설정
$ten=5; // 한 화면에 표시될 페이지 번호의 수
$page = $_GET[page];
//검색어 정의
if ($keyword!="")
{
$sql_where = " where $keyfield like '%$keyword%' ";
}//if

//전체 글수 계산
$total_sql = "select count(*) from board3 ";
$total_sql .= $sql_where;//검색조건
$res = mysql_query($total_sql);

$total_count = mysql_result($res,0,0);

$totpage = ceil($total_count/$ipp);//총 페이지수 연산

$page = min(max(1,$page),$totpage); // 1< 출력할 페이지 번호 <전체 페이지수
//현재페이지의 시작레코드를 찾습니다.
$startrow = ($page - 1) * $ipp;

//현재 페이지에 출력할 레코드 선택질의
$list_sql = "select * from board3 ";
$list_sql .=  $sql_where;//검색조건
$list_sql .= " order by groupnum desc, stepnum asc";//정렬조건
$list_sql .= " limit $startrow, $ipp ";//한 페이지에 출력할 글수 제한

$res = mysql_query($list_sql);

?>

<table width="650" height="24" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td>&nbsp;</td>
    <td align="right">Total <? echo number_format($totpage);?> pages / <? echo number_format($total_count);?>
      items</td>
  </tr>
</table>

<table width="650" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr align="center" bgcolor="#EBE8D8">
<td width="50" height="24">번호</td>
    <td width="40" align=left bgcolor="#EBE8D8">종류</td>
    <td>제목</td>
    <td width="50" bgcolor="#EBE8D8">작성자</td>
    <td width="80">등록일</td>
    <td width="50">조회</td>
  </tr>
 <?
if ($res)
{
$i=0;
while ($rs = mysql_fetch_array($res))
{


?>
<tr bgcolor="<?
  if ($rowid==$rs[rowid])
{
  echo "#e0e0e0";
}
else
{
  if ($i%2==0)
echo "#f0f0f0";
else
echo "#eaeaea";
}
  ?>"> <!--<td height="24" align="center"><? echo $rs[rowid];?></td> 글의 등록번호-->
<td height="24" align="center"><? echo $i?></td> // 번호 출력부분
<td align="left">
<? if ($rs[assin]=="긴급") {?>
<? echo $rs[assin];?>
<? } if($rs[assin]=="일반") {?>
<? echo $rs[assin];}?>
</td>
<td style="cursor:hand;" onClick="self.location='list.php?rowid=<? echo $rs[rowid];?>&rowid2=<? echo $rs_user[rowid];?>';">
<?
for ($d=0;$d<$rs[depth];$d++) echo "&nbsp;&nbsp;";
if ($rs[stepnum]>0) echo '<img src="img/icon_sub.gif" align="absmiddle">';
?>
<? echo str_limit($rs[subject],50,"...");?></td>
<td align="center"><? echo str_limit($rs[name],8,"");?></td>
<td align="center"><? echo substr($rs[input_date],0,10);?></td>
<td align="center"><? echo number_format($rs[access]);?></td>
</tr>
<?
$i++;  // 증가값
}//while
}//if

$block = ceil($page / $ten); // 현재 화면에 표시할 링크 블록 번호
$startpage = ($block - 1) * $ten + 1; // 첫번째 링크 번호
$endpage = min($startpage + $ten - 1, $totpage); // 마지막 링크번호

?>

</table>
<table width="650" height="40" border="0" align="center" cellpadding="5" cellspacing="0" bgcolor="#EBE8D8" style="border:0px #333333 solid;border-bottom-width:3px;">
  <tr>
    <td>
        <table border="0" cellpadding="0" cellspacing="0">
          <tr valign="bottom">
            <td style="color:#333333;font-size:12px;"><span style="font-weight:bold;">Go
              to Page:</span> &nbsp;
              <? if ($startpage>1) { ?>
              <a style="cursor:hand;color:#333333;font-weight:;font-size:12px;" onClick="search_form.startpage.value='1'; search_form.page.value='1';search_form.submit();">◀</a>
              <a style="cursor:hand;color:#333333;font-weight:;font-size:12px;" onClick="search_form.startpage.value='<? echo $page-$ten;?>';search_form.page.value='<? echo $page-$ten;?>';search_form.submit();">Prev</a>
              <? }//if ?>
              <?

for ($j=$startpage;$j<=$endpage;$j++) {

if ($page==$j)
{
echo "<b>[$j]</b>";
}
else
{
echo "<a href=\"javascript:search_form.page.value='$j';search_form.submit();\">"; // 페이지번호값 넘겨주는 부분
echo "[$j]";
echo "</a>";
}
}//for
?>
              <? if ($endpage<$totpage) { ?>
              <a style="cursor:hand;color:#333333;font-weight:;font-size:12px;" onClick="search_form.startpage.value='<? echo $page+$ten;?>'; search_form.page.value='<? echo $page+$ten;?>';search_form.submit();">Next</a>
              <a style="cursor:hand;color:#333333;font-weight:;font-size:12px;" onClick="search_form.startpage.value='<? echo $totpage;?>'; search_form.page.value='<? echo $totpage;?>';search_form.submit();">▶</a>
              <? }//if ?>
              &nbsp;</td>
          </tr>
        </table>
    </td>
    <td align="right">
<form action="list.php" method="get" name="search_form" id="search_form" style="margin:0px;">
        <table border="0" cellspacing="0" cellpadding="0">
          <tr><input type="hidden" name="rowid2" value="<? echo $rs_user[rowid]; ?>">
            <td> <input name="page" type="hidden" id="page">
<input name="startpage" type="hidden" id="startpage">
              <select name="keyfield" id="keyfield">
                <option value="subject" <? if($keyfield=="subject") echo "selected";?>>제목</option>
                <option value="assin" <? if($keyfield=="assin") echo "selected";?>>종류</option>
<option value="name" <? if($keyfield=="name") echo "selected";?>>이름</option>
              </select></td>
            <td><input name="keyword" type="text" id="keyword" value="<? echo $keyword;?>" size="12">
            </td>
            <td>
<input type="submit" name="Submit" value="Search"></td>
          </tr>
        </table>
        </form></td>
  • 복사

댓글 전체

$i=0; 말고 $i = $ten ; 하시면 제일 위가 5가 되고요

상단이 남은 수에 따라 변경 되실려면 아래 부분을
while ($rs = mysql_fetch_array($res))
{


?>
<tr bgcolor="<?
  if ($rowid==$rs[rowid])
{
  echo "#e0e0e0";
}
else
{
  if ($i%2==0)
echo "#f0f0f0";
else
echo "#eaeaea";
}
  ?>"> <!--<td height="24" align="center"><? echo $rs[rowid];?></td> 글의 등록번호-->
<td height="24" align="center"><? echo $i?></td> // 번호 출력부분



아래와 같이 변경하시면 됩니다

//---------------------------------
$view_num = $ten ;
if($startrow + $ten >= $total_count )
{
$view_num = $total_count % $ten ;
}
//---------------------------------
while ($rs = mysql_fetch_array($res))
{


?>
<tr bgcolor="<?
  if ($rowid==$rs[rowid])
{
  echo "#e0e0e0";
}
else
{
  if ($i%2==0)
echo "#f0f0f0";
else
echo "#eaeaea";
}
  ?>"> <!--<td height="24" align="center"><? echo $rs[rowid];?></td> 글의 등록번호-->
<td height="24" align="center"><? echo $view_num ; $view_num--;?></td> // 번호 출력부분
© SIRSOFT
현재 페이지 제일 처음으로