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
Database connection failure
Hello All,
I am trying to create new connection to Oracle DB 10.1,
I could not see a
Refining of search Criteria
Dear Friends
I need a help, I have a search page which of cars related, which has different s
Easy administration on MySQL databases
My website is database driven and I am very tired of manually making queries to my tables in order t
TemplatePower & AJAX
Hi all,
I'm currently implementing some AJAX features in my PHP-framework (which is b
Navigation include for all site directories
Hi,
I need a navigation include that can deal with directories at different levels on a site.
Problem executing bash script using shell_exec
Hi there,
I created a bash script file using following code to convert doc documents to pdf using
Unable to customise toolbar in FCK
SMTP server...
I recently found a tutorial online on SMTP authentification for sending emails from webpages, here i
PHP Include not working
The website is http://www.grlistingservices.com
The code block is as follows:
<
Inserting a check in checkbox from array value
Hello all,
I have a bit of code that works for a select option box, but does not work for my chec