This is exactly what I sent you.
You have to realize that you can't print down one column, and then start a
new one.
You have to print across, left to right before you go down.
You have to modify the print statement to put it into a table, but that is
easy:

Print should be:
printf("<tr><td>%s</td><td>%s</td><td>%s</td></tr>",$items[$i],$items[$i+3],
$items[$i+6]);

That will print your 3 columns in a table.
And it is essentially identical to to what I sent. Just have to modify the
format of the printf statement.

You can also do it in a regular print statement:

Print("<tr><td>$items[$i]</td><td>$items[$i+3]</td><td>$items[$i+6]</td></tr
>\n");


Or how about a here doc for php4
Print <<EOF
<tr><td>$items[$i]</td><td>$items[$i+3]</td><td>$items[$i+6]</td></tr>\n
EOF

The for loop stays the same, only the print statement changes.

Lindsay Adams
---



On 4/7/01 4:55 PM, "DRN" <[EMAIL PROTECTED]> wrote:

> 
> Lindsay Adams <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> | Assuming your items are in an array
> | $items =array() //assume a bunch of items in this array
> | For($i = 0; $i< (count($items)/3); $i +=1){
> |     printf("%s\t%s\t%s",$items[$i],$items[$i+3],$items[$i+6]);
> | }
> |
> | Should print 3 columns of tab separated text.
> | Note: typed this quickly, untested, but the theory is sound. Might
> have to
> | twiddle the $i<(count... Section.
> |
> | If you have 8 itesm, as shown and you divide by 3 you get 2.xx
> | So, the the loop will print out:
> |
> | $items[0]   $items[3]   $items[6]
> | $items[1]   $items[4]   $items[7]
> | $items[2]   $items[5]   $items[8}
> | // because $items[8] doesn't exist, it won't print.
> | // if it spits out an error there, put a @in front of printf to turn
> off
> | error reporting.
> |
> |
> | On 4/7/01 11:58 AM, "Jack Dempsey" <[EMAIL PROTECTED]> wrote:
> |
> | > You don't need to count...in your loop you can do something like
> this:
> | > if($current_pos%3==0){    //then you're at a multiple of three
> | > //code to start new column here
> | > }
> | >
> | > -jack
> | >
> 
> Neither of these were quite what I was looking for, I was hoping I
> could make a table with 3 <td>'s side by side, each having a third of
> the list of products (with <br> between them).
> Is this possible? If not I will try to adapt one of these methods.
> 
> Cheers for your help, Donald
> 
> 


-- 
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