본문 바로가기
MySql

MySQL Echo current number of row

by 베이스 공부 2020. 11. 19.
반응형

내 $ num_rows는 총 행 수를 에코하지만 현재 행 번호를 원합니다.

<?php
$result = mysql_query('SELECT * FROM texts ORDER BY id desc');
while($row = mysql_fetch_array($result)){
$num_rows = mysql_num_rows($result);
?>
<tr class="alt">
    <td><?php echo $row['id']; ?></td>
    <td><?php echo $row['title']; ?></td>




</tr> <?php } ?>

감사합니다 :)

 

해결 방법

 

while 내부의 루프 회전을 계산하기 위해 증분 변수를 사용해서는 안되는 이유는 무엇입니까?

$tmpCount = 1;
while() {

   $tmpCount ++;
}

도움이 되셨나요? 또는 데이터베이스에서의 물리적 행 번호를 예상하고 있습니까?

 

참조 페이지 https://stackoverflow.com/questions/3125197

 

 

반응형

댓글