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
Help with Contact Form
I have this Form on an html page and the associated code on page.php (below).
I keep getting the
Login Control?!
I have a Web Site that uses the login control also I have set the destinationurl to the page I want
Header is not working in IE
Hi ! header function is not working in IE but it works in FF, Safari, Chrome. any help please. :
Multiple server callbacks (NOT POSTBACKS)
Hello,
I have 2 different javascript client side functions that are on timers. When the timers elap
Data storage spaces in varchar2
Trying to understand what's happening.
I am selecting a value from a table that is defined as c
creating a 1 to 100 in a table
hi guys I am a newb in php need some help.
I have a table with 1 column and 100 rows and in
Parse XML
Good day,
I use oempro software and try to parse XMLReturn but it's not working for me, simpl
xml element exists
Code: [Select]<?xml version="1.0"?>
<Addresses>
<
=> and <=
So I was digging through some code when I came across the <= operator. This is the first tim
an interesting question
Greetings folks, got to ask an interesting question...
let say
i have created a function s