php

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • manisha gupta
    New Member
    • Jan 2012
    • 1

    php

    i want get next and previoes row information in mysql_fetch_arr ay in whilew loop with the current row

    Code:
    while($result=mysql_fetch_array($sqlcate1)){
    				?>
    
                    <tr class=gradeX>
                      <td><?php echo $m++;?></td>
                      <td><?php echo $result['cat_name']?></td>
                      <td><?php echo $result['title'];?></td>
              
                      <td valign="top" align="center"><img src="http://bytes.com/topic/php/images/thumbs/<?php echo $result['image_name']?>" width="65"   />
                        <?php #echo tep_image("../images/photo/".$result['table_name'],'',100,80); ?></td>
                      <td class=center><img onclick="location.href='<?php FILENAME_ADMIN_AREA ?>?content=<?php echo CONTENT_ADMIN_IMAGE; ?>&id=<?php echo $result['id']; ?>&action=edit_images' " style="cursor:pointer" src="http://bytes.com/images/pencil2.png"><img src="http://bytes.com/images/delete_icon.gif" id="<?php echo $result["id"]; ?>" style="cursor:pointer" class="delbutton">
                      <?php if($result['order']!=0){?> &nbsp;<img src="http://bytes.com/images/up.jpg" alt="move down"  border="0" /> <? } ?>
                      <?php if($result['order']!=($count-1)){?> &nbsp; <img src="http://bytes.com/images/down.jpg" alt="move up"  border="0" /> <? } ?>
                      </td>
                    </tr>
                    <?php
    				}
    i want information of current and previous row alos
    Last edited by Dormilich; Jan 5 '12, 12:10 PM. Reason: please use [CODE] [/CODE] tags when posting code
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    nope. with mysql_fetch_ass oc() you can only get one row at a time in sequential order. you would have to use PDO’s fetchAll() or MySQLi’s fetch_all() method to convert the result in an array, where you can have that access.

    Comment

    • Rabbit
      Recognized Expert MVP
      • Jan 2007
      • 12517

      #3
      Or if memory is an issue, you can store that info in variables. of course that means you have to read the first 3 rows before you can start processing the second row which is designated as the "current row".

      Comment

      Working...