AlexTheTaco Posted February 4, 2010 Share Posted February 4, 2010 Hi, I'm having some trouble with my PHP code and thought I should come over here. I've been watching the show for a while and never really looked at the forum. Anyway, here we go. <?PHP for ($x = 0; $x < sizeof($members['MemberName']); $x++) { echo "<a href='logs/".$members[$x]["MemberName"].".html'>".$members[$x]["MemberName"]."</a><br>"; } ?> it doesnt return anything with this data in the members array Array ( [0] => Array ( [MemberName] => willmaster [MemberUserID] => 290668 [MemberKeys] => 6872 [MemberClicks] => 6450 [MemberManager] => No [MemberCountry] => Canada ) [1] => Array ( [MemberName] => munktube1 [MemberUserID] => 290672 [MemberKeys] => 6998 [MemberClicks] => 1174 [MemberManager] => Yes [MemberCountry] => Unknown ) [2] => Array ( [MemberName] => ajvpot [MemberUserID] => 290674 [MemberKeys] => 8437 [MemberClicks] => 4086 [MemberManager] => Yes [MemberCountry] => United States ) ) Any ideas? Or am i just stupid and forgot something ovbious? :) Quote Link to comment Share on other sites More sharing options...
Netshroud Posted February 5, 2010 Share Posted February 5, 2010 Shouldn't it just be "sizeof($members)" ? Quote Link to comment Share on other sites More sharing options...
MRGRIM Posted February 5, 2010 Share Posted February 5, 2010 Psychosis is right FYI http://php.net/manual/en/function.sizeof.php Quote Link to comment Share on other sites More sharing options...
ElementalWarrior Posted February 10, 2010 Share Posted February 10, 2010 yep he is, I was going to say just use count(), lol but they point to the same function anyways :P Just a tip, try to have very pretty formatting, for example this: <?PHP for ($x = 0; $x < sizeof($members['MemberName']); $x++) { echo "<a href='logs/".$members[$x]["MemberName"].".html'>".$members[$x]["MemberName"]."</a><br>"; } ?> Might look better like this: <?PHP for ($x = 0; $x < sizeof($members['MemberName']); $x++) { echo "<a href='logs/".$members[$x]["MemberName"].".html'>".$members[$x]["MemberName"]."</a><br>"; } ?> Oh, and isn't it better to use <br /> instead of <br>, if I remember right, <br /> is valid for both loose and strict DOCTYPES Quote Link to comment Share on other sites More sharing options...
Kristoffer Hagen Posted March 5, 2010 Share Posted March 5, 2010 You should probably use a foreach loop instead, like this: <?php $members = Array( 0 => Array( 'MemberName' => 'willmaster', 'MemberUserID' => '290668', 'MemberKeys' => '6872', 'MemberClicks' => '6450', 'MemberManager' => 'No', 'MemberCountry' => 'Canada' ), 1 => Array( 'MemberName' => 'munktube1', 'MemberUserID' => '290672', 'MemberKeys' => '6998', 'MemberClicks' => '1174', 'MemberManager' => 'Yes', 'MemberCountry' => 'Unknown' ), 2 => Array( 'MemberName' => 'ajvpot', 'MemberUserID' => '290674', 'MemberKeys' => '8437', 'MemberClicks' => '4086', 'MemberManager' => 'Yes', 'MemberCountry' => 'United States' ) ); foreach ($members as $member) { echo '<a href="logs/' . $member["MemberName"] . '.html">' . $member["MemberName"] . '</a><br />'; } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.