Q:

php & mysql while loops

I'm new in PHP and I think this is an easy question.
I can show the content that comes from my db this way:
...
...
 <?php while($rows = mysql_fetch_array($queryNews)){    ?>
  <div class='title_news'><?php echo $row['Title'] ?> </div>
.... and so on... 

Thats ok so far
Then I want to simulate a kind of pagination: I mean showing as many numbers as news
I first tried a for-loop
<?php for($i=1; $i<= sizeof(mysql_fetch_array($queryNews)); $i++){ ?>
    <div class="num_txt"><?php echo $i ?></div>
<?php } ?>

No success. so I tried an similar  way as the first one, also without success.
    <?php 
        $i=1;
        while($row = mysql_fetch_array($queryNews)){    ?>
        echo '<script language="javascript">confirm('.$i.')</script>;';
            <div class="num_txt"><?php echo $i ?></div>
   <?php $i++; } ?>

Does anyone knows what I'm doing wrong??
Thanks

A:

Your for loop was almost correct, but sizeof(mysql_fetch_array($queryNews)) fetches a row from the result set and returns the number of columns in that row.  You want the number of rows in the result set:
<?php for($i=1, $numRows = mysql_num_rows($queryNews); $i<= $numRows; $i++){ ?>
    <div class="num_txt"><?php echo $i ?></div>
<?php } ?>

