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>
Did you know?Explore Trending and Topic pages for more stories like this.
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
48
Other forums
Function
How can I make this function that once you click the link in the code it takes you to a new page wit
ob_ dynamic content
i was wondering about the potential to use ob to create a <div then remove it when the page
php problem?
I don't think I'm stupid, but maybe I am.
I am working on a sit for a friend I am try to put
Form help: Syntax & Logic
Hello again all,
I'm working on a form and ran into a wall (again) and can't seem to think th
Save User Inputs while javascript reloading!
hi..
i have written a PHP code in which i reload the page when user selects a value in dropdown..
database design
Hi,
I got a page which allow candidate to type in their previous working experience,
I let
HTML Email rec'd as Source Code
The code does create and send the email successfully. However, the message shows as html code and n
PHP switch function help
Hi, I am trying to create a search function for a directory website. On the search function on html
need a script for 3 pages
I have a customer who wants me to set up a site with a number of pages with the following requiremen
Socket Server
In my following socket server, I am trying to listen to a connection through port 12345 in my web br