Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.