Hi,

You are really messed up with this 'if' statement.
What you want is nicely described, so I won't repeat it, just make some correction...

function array2links($cat, $arr) 
{
    $i = 0;
    $cat = rawurlencode($cat);
    while ( list( $key, $val ) = each($arr)) 
    {
         $out .= "<a class=\"cats\" href=\"products.php?Cat=$cat&Code=$key\" 
title=\"$val\">$val</a><br>";
         if ( $i == 5 ) {
             $out .= "</td><td valign=\"top\">";
             $i = 1;
         }
         else $i++;
     }
     return $out;
 }

----- Original Message ----- 
From: "Joseph Blythe" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: 2001. május 4. 08:02
Subject: [PHP] array 2 links


> Hello,
> 
> I seem to be having some difficulty understanding why the following function skips 
>every 5th array item, 
> basically the following function takes two parameters category and an array, when 
>placed inside a table it will generate
> links based on the array items splitting the table into columns when more than 4 
>links have been generated. 
> However as mentioned every 5th array item is skipped hmm..
> 
> The solution is probably really obvious but I can't seem to see it!
> 
> function array2links($cat, $arr) {
> $i = 0;
> $cat = rawurlencode($cat);
> while ( list( $key, $val ) = each($arr)) {
> 
> $link = "<a class=\"cats\" href=\"products.php?Cat=$cat&Code=$key\" 
>title=\"$val\">$val</a><br>";
> if ( $i < 4 ) {
> $out .= "$link";
> } else {
> $out .= "</td><td valign=\"top\">";
> $i = 0;
> continue;
> }
> $i++;
> }
> return $out;
> }
> 
> Any help/ideas would be appreciated,
> 
> Regards,
> 
> Joseph.
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to