fife Posted March 9, 2011 Share Posted March 9, 2011 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 More sharing options...
AbraCadaver Posted March 9, 2011 Share Posted March 9, 2011 while($CP = mysql_fetch_assoc($Link)) { Link to comment https://forums.phpfreaks.com/topic/230126-re-using-array/#findComment-1185142 Share on other sites More sharing options...
fife Posted March 9, 2011 Author Share Posted March 9, 2011 If I change that line to while then I get an error from the server that states theres an unexpected ; in that line Link to comment https://forums.phpfreaks.com/topic/230126-re-using-array/#findComment-1185212 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.