grouping within a foreach?


Posted on 16th Feb 2014 07:03 pm by admin

hello all,

I currently have a list of products spit out from my db via a foreach loop. Right now I am styling these as a <li>

I want to style the list so that the annual and the monthly products are grouped together. This will probably mean using <div> instead of <li> and placing another loop inside the foreach to grab two products and put them in one div?

Any ideas how this might be structured??

should I use a for loop?

here is the current code:
Code: $productnames = '<center><table><tr><td><ul id="prodlist">'."n"; // list of products that can view this content
$show2all = false; // are one of the products the "all" flag?
$numcanview = 0; // the number of products that can view this post

foreach ($_product_id as $pid)
{

$pid = trim(strtolower($pid)); // make sure no extra spaces and not "ALL" or something

if ($pid=="all")
{

$show2all = true; // used later

} else {

$purl = $this->amprotectamroot.'member.php?price_group='.$allthepricegroups[$pid].'&product_id='.$pid;

$productnames .= '<li><a href="'.$purl.'">'.$alltheproducts[$pid].'</a></li>'."n";

$numcanview++;

}

No comments posted yet

Your Answer:

Login to answer
103 Like 48 Dislike
Previous forums Next forums
Other forums

restricting another login once you logout
Hello,

how can I restrict a page from login authenticating against info in a MySQL DB for a s

background color imagefill
Hello

I would like to ask you why I see this square in red color just in my local xampp insta

SCO Unix
I know this might not be the place to ask, but, can anyone tell me if SCO Unix comes with PHP built

PHP/PKI
I am trying to set up a web application that uses pki. does anyone have a good tutorial to set this

Auto install
Hi I have a directory lets say "apps" that I then have more folders ie "email",

Select question
Hi,

First I would like to say that php is pretty new for me..
so please don't shoot me if

AutoChoosing a CSS file based on URL
Hey everyone,

I have a site that has multiple URLs and CSS files.

Based on the URL tha

Appending GET data with form submition
Okay, what I'm trying to do is to use a form to append an already existing GET data string.

I

Embed Video Problem
Hey, thanks for looking!

File to be embedded:

Code: <playlist version="1&q

Help with Contact Form
I have this Form on an html page and the associated code on page.php (below).
I keep getting the

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash