mysql_fetch_array not display first row

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • azmanamir
    New Member
    • Oct 2015
    • 1

    mysql_fetch_array not display first row

    Here i want to display all the columns but i have getting all the columns except first one. How i can get first one ? Anyone can help me to solve this problem.
    Code:
    <form method='get'>
                        
       <?php
    
    if (!isset($_GET['startrow']) or !is_numeric($_GET['startrow'])) {
      //we give the value of the starting row to 0 because nothing was found in URL
      $startrow = 0;
    //otherwise we take the value from the URL
    } else {
      $startrow = (int)$_GET['startrow'];
    }
    
    $result = mysql_query("select s.s_id,s.s_name, DATE_FORMAT(s.s_date,'%d/%m/%Y'),DATE_FORMAT(s.s_emaildate,'%d/%m/%Y'),s.s_category,s.p_jawab,a.sc_category,b.staff_username from soal_jawab s, category a, staff b 
    where s.s_category = a.sc_id 
    and s.p_jawab = b.ic_num 
    and s.s_category = 'SC1'
    LIMIT $startrow, 10;")or
    die(mysql_error());
    $num=mysql_fetch_array($result);
    
    if($num>0)
        {    
    	?>               
    <table id="rounded-corner">
        <thead>
        	<tr>
                <th>NO.SIRI</th>
                <th>TARIKH TERIMA EMAIL</th>
                <th>KATEGORI</th>
                <th>PANEL PENJAWAB</th>
                <th>TARIKH SERAH SOALAN</th>
                <th>TARIKH BALAS EMAIL</th>
                <th>KEMASKINI</th>
                <th>PADAM</th>
            </tr>
        </thead>
            <tfoot>
        	<tr>
            	<td colspan="12"></td>
            </tr>
        </tfoot>
        
    <?php
    for($i=-1;$i<$num;$i++)
    {
    $num = mysql_fetch_array($result);
    ?>
    
        <tbody>
        	<tr class="odd" onclick="window.document.location='butiransoalan.php?s_id=<?php echo $num[0];?>';">
            	
                <td><?php echo $num['s_id'];?></td>
                <td><?php echo $num[3];?></td>
                <td><?php echo $num['sc_category'];?></td>
                <td><?php echo $num['staff_username'];?></td>
                <td><?php echo $num[2];?></td>
                <td></td>
                <td><a href="#"><img src="images/edit.png" alt="" title="" border="0" /></a></td>
                <td><a href="#"><img src="images/trash.gif" alt="" title="" border="0" /></a></td>
                
            </tr>
      
            
        </tbody>
        <?php } ?>
    </table>
    <?php } ?>
    
    <?php
    
    echo '<a href="'.$_SERVER['PHP_SELF'].'?startrow='.($startrow+10).'">Next</a>';
    
    $prev = $startrow - 10;
    
    //only print a "Previous" link if a "Next" was clicked
    if ($prev >= 0)
        echo '<a href="'.$_SERVER['PHP_SELF'].'?startrow='.$prev.'">Previous</a>';
    ?>
    </form>
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    you fetch the first result set on line #19 for the table head, but do not use its data. hence you’re missing the first result set in the table body.

    Comment

    Working...