I’m creating a new website, I don’t want to link direct to it so I’ll put spaces inbetween:
test . glow – sticks . org
I have a list of the 15 most popular products on the right hand side of the page (WHATS HOT), I would like to show a number for each one, the first being 1 and the last being 15.
I am a php noob, but despite reading about using range and foreach at the php manual site, I’m struggling to show numbers. I’ve found it easy to show the same range of numbers for each product block, e.g 1,2,3…15 showing 15 times, but this obviously isn’t what I’m trying to do.
I probably need to give more info than I have here, so I’ll past the code that I’m working with on the php include:
<div id="whatshot_smallblock">
<a href='/<?=str_replace(" ","-",$productname)?>.html'><img src='http://www.glow-sticks.org/images/products/<?=$productimage?>' alt='<?=$productname?>' width='66' height='66' hspace="2" vspace="2" border='0' class="radius" />
</a>
<div id="whatshot_smallblock_Txt">
<a href='/<?=str_replace(" ","-",$productname)?>.html'><?=$productname?></a><br><div id="pink_color"><span class="content_2"><?=$minprice_dis?></span><?=$_SESSION['currsymbol']?><?=$minprice?></div></div>
<div id="bigblacknumbers"></div></div>
and in my objectmanager php file I can see the code relating to the whatshot section:
//what's hot
function whatshotids() {
if( !isset( $this->dblink ) )
dbconnect();
//$sql = "SELECT COUNT(pid) AS repetitions, pid FROM gs_orderlines GROUP BY pid ORDER BY repetitions DESC LIMIT 15";
$timenow = time();
$checktime = ($timenow - 1814400); // 3 weeks
$sql = "SELECT COUNT(pid) AS repetitions, gs_orderlines.pid FROM gs_orderlines INNER JOIN gs_orders ON gs_orders.oid =
gs_orderlines.oid WHERE gs_orders.datetime >= $checktime GROUP BY gs_orderlines.pid ORDER BY repetitions DESC LIMIT 15";
$result = mysql_query( $sql, $this->dblink )
or die( "Invalid query Line 1018" );
$i = 0;
$whids = array();
while( $row = mysql_fetch_object( $result ) ) {
////
$sql2 = "SELECT * from gs_inventory WHERE pid = ".$row->pid. " AND display_product='1' AND stock>0 AND canbackstock!='yes'";
$result2 = mysql_query( $sql2, $this->dblink );
if($row2 = mysql_fetch_object( $result2 )){
$whids[$row->pid] = $row->repetitions;
$i = $i + 1;
}
...
}
...
}
Hopefully this is enough or too much information.
Many thanks!
It seemed that the only thing I needed to do was to enter:
And it just started counting from the first iteration.