Jump to content

re-using array


fife

Recommended Posts

I have this code which gets in an array all the current activities i'm a member of.  I then want to use my array time and time again.  the problem I have is im already using it and because I dont know enough php I cant figure out how to re-use it.  Here is the code I have......

 


<?php 
          for($i = 0; ($CP = mysql_fetch_assoc($Link) && $i < 3; $i++ ){ ?>
     <table width="50" border="0" cellpadding="0" cellspacing="0" id="list_of_clubstbl">

  <tr>
    <th width="34" scope="col"><a href="<?php echo $CP['clubID'];?>"><img name="<?php echo $CP['cover'];?>" src="" width="50" height="50" alt="<?php echo $CP['name'];?> " /></a></th>
    </tr> 
<tr>
<td><?php 
if ($CP['permission']=='1') {echo " <a class=\"ownertext\" href=\" {$CP['clubID']}\">{$CP['name']}</a>";}
elseif ($CP['permission']=='2') {echo "<a class=\"admintext\" href=\" {$CP['clubID']}\">{$CP['name']}</a>>";}
elseif ($CP['permission']=='3') {echo "<a class=\"stafftext\" href=\" {$CP['clubID']}\">{$CP['name']}</a>";}
elseif ($CP['permission']=='4') {echo "<a class=\"membertext\" href=\" {$CP['clubID']}\">{$CP['name']}</a>";}
 ?></td>
    </tr>

</table>
<br/>
  <?php } ?>

 

Where I have used ($CP = mysql_fetch_assoc($Link);) && $i < 3; $i++ ) I understand I'm fetching the array and limiting it by 3.  Once I have done mysql_fetch_array on the $Link I see it can not be used again.  Is there a way to create this loop so I'm not limiting the TOTAL array by 3.  Does that even make sense?

Link to comment
https://forums.phpfreaks.com/topic/230126-re-using-array/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.