By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,117 Members | 1,093 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,117 IT Pros & Developers. It's quick & easy.

php

P: 1
i want get next and previoes row information in mysql_fetch_array in whilew loop with the current row

Expand|Select|Wrap|Line Numbers
  1. while($result=mysql_fetch_array($sqlcate1)){
  2.                 ?>
  3.  
  4.                 <tr class=gradeX>
  5.                   <td><?php echo $m++;?></td>
  6.                   <td><?php echo $result['cat_name']?></td>
  7.                   <td><?php echo $result['title'];?></td>
  8.  
  9.                   <td valign="top" align="center"><img src="http://bytes.com/topic/php/images/thumbs/<?php echo $result['image_name']?>" width="65"   />
  10.                     <?php #echo tep_image("../images/photo/".$result['table_name'],'',100,80); ?></td>
  11.                   <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">
  12.                   <?php if($result['order']!=0){?> &nbsp;<img src="http://bytes.com/images/up.jpg" alt="move down"  border="0" /> <? } ?>
  13.                   <?php if($result['order']!=($count-1)){?> &nbsp; <img src="http://bytes.com/images/down.jpg" alt="move up"  border="0" /> <? } ?>
  14.                   </td>
  15.                 </tr>
  16.                 <?php
  17.                 }
i want information of current and previous row alos
Jan 5 '12 #1
Share this Question
Share on Google+
2 Replies


Dormilich
Expert Mod 5K+
P: 8,639
nope. with mysql_fetch_assoc() you can only get one row at a time in sequential order. you would have to use PDOs fetchAll() or MySQLis fetch_all() method to convert the result in an array, where you can have that access.
Jan 5 '12 #2

Rabbit
Expert Mod 10K+
P: 12,364
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".
Jan 5 '12 #3

Post your reply

Sign in to post your reply or Sign up for a free account.