Jump to content

Recommended Posts

Posted

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? :)

Posted

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

  • 4 weeks later...
Posted

You should probably use a foreach loop instead, like this:

&lt;?php

$members = Array(
    0 =&gt; Array(
        'MemberName' =&gt; 'willmaster',
        'MemberUserID' =&gt; '290668',
        'MemberKeys' =&gt; '6872',
        'MemberClicks' =&gt; '6450',
        'MemberManager' =&gt; 'No',
        'MemberCountry' =&gt; 'Canada'
    ),
    1 =&gt; Array(
        'MemberName' =&gt; 'munktube1',
        'MemberUserID' =&gt; '290672',
        'MemberKeys' =&gt; '6998',
        'MemberClicks' =&gt; '1174',
        'MemberManager' =&gt; 'Yes',
        'MemberCountry' =&gt; 'Unknown'
    ),
    2 =&gt; Array(
        'MemberName' =&gt; 'ajvpot',
        'MemberUserID' =&gt; '290674',
        'MemberKeys' =&gt; '8437',
        'MemberClicks' =&gt; '4086',
        'MemberManager' =&gt; 'Yes',
        'MemberCountry' =&gt; 'United States'
    )
);

foreach ($members as $member)
{
    echo '&lt;a href="logs/' . $member["MemberName"] . '.html"&gt;' . $member["MemberName"] . '&lt;/a&gt;&lt;br /&gt;';
}

?&gt;

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.   Paste as plain text instead

  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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...