Hi can someone tell me what I have to change i my code to let the output be in 2 collumns instead of one.
If its possible it could be nice to have the top 10 list like this:
1 2
3 4
5 6
7 8
9 10
Here is my code, Thanks:
echo "\n<h2>Top 10 Coupons</h2>";
db_connect ($cfg["db_server"], $cfg["db_user"], $cfg["db_pass"], $cfg["db_database"]);
$sql_sms = ("SELECT FROM sms");
$result_sms = db_query ($sql_sms);
$row_sms = mysql_fetch_array($result_sms);
$sms_enabled = $row_sms['enabled'];
$now = time();
$sql = "SELECT ,c.expire as exdate, b.business as business FROM coupons c,businesses b,users u WHERE c.business=b.business and u.user=b.user and u.billing=1 and c.approved=1 order by c.prints DESC";
$result = db_query ($sql);
//echo "$sql";
echo "\n\t<table width='100%' cellpadding='4' class='coupon' style='table-layout:fixed;'>\n";
$i=3;
$num = 0;
while (($row=mysql_fetch_object($result)) && ($num < 10)) {
if (isDateExpired($row->exdate)) {
continue;
}
if ($i==3) {$i=2;}
if ($i==2) {echo "\n<tr>";$i=0;}
echo "\n<!-- begin coupon $num -->";
echo "\n\t<Tr>";
$id = $row->coupon;
$ids[][0] = $id;
$j=count($ids) - 1;
$ids[$j][1] = $row->views;
unset ($coupon);
$busname = $row->name;
$busId = $row->business;
$coupon[] = $row->name;
$coupon[] = $row->title;
$coupon[] = $row->price;
$coupon[] = $row->subtitle;
$coupon[] = $row->terms;
$coupon[] = $row->exdate;
$coupon[] = $row->views;
$coupon[] = $row->prints;
$coupon[] = "barcodes/". $row->barcode;
$coupon[] = $id;
$coupon[] = $row->business;
if ($row->couponlogo == 'yes') {
$coupon[] = 'coupon'.$id.'.jpg';
}
echo "\n\t\t<td width='100%' align='center' valign='top'>";
print_coupon ($coupon,2,$cfg);
$i++;
echo "\n\t\t</td>";
echo "\n\t</tr>";
echo "\n<!-- end coupon $num -->";
$num++;
}
mysql_close();
if ($i==1) {echo"<td width='50%'>";}
echo "</table>";
//increment view information for each coupon
for ($i=0;$i<count($ids);$i++) {
db_connect ($cfg["db_server"], $cfg["db_user"], $cfg["db_pass"], $cfg["db_database"]);
$views = ($ids[$i][1]) + 1; $coupon = $ids[$i][0];
$sql = "update coupons set views='$views' where coupon='$coupon'";
$result = db_query ($sql);
mysql_close();
}