Hej jag har tappat greppet så jag undrar om det är någon vänlig själ som skulle kunna hjälpa mig?
Det är så att jag vill ha tre celler i rad sedan rad byte i tabellen sen 3 i rad igen så här
Cell Cell Cell
Cell Cell Cell
har jag gjort så här men den vill inte byta rad
//Show products mainPage 3 in row.
function window_top($itemCatName,$i) {
global $i;
$ret = "<tr bgcolor='' height='30'>";
$ret .= "<td>";
echo $i;
$ret .= "<tr><td>";
$ret .= "<table width='160' height='130' cellspacing='0' cellpadding='8' border='1'>";
if($i==0){
$ret .= "<tr>";
}
return $ret;
}
function window_product($row_prod,$doId,$count,$i) {
$ret = "<td width='160' height='130' valign='top' align='center'>";
$ret .= "<table border='0' cellpadding='0' cellspacing='0' width='160'>";
$ret .= "<tr bgcolor='#BFD634' height='30'>";
$ret .= "<td class='box_topleft' width='10'></td>";
$ret .= "<td background='img/gifs/box_topmiddle.gif'><span class='headerOrderStart'> </span></td>";
$ret .= "<td class='box_topright' width='10'></td>";
$ret .= "</td>";
$ret .= "</tr>";
$ret .= "</table>";
$ret .= "<table class='orderTableBottom' border='0' cellpadding='10' cellspacing='0' width='160' height='230' background='img/gifs/RamOrnamentTBottom.gif'>";
$ret .= "<tr height='' valign='top'><td>";
$ret .= "<img src='img/pageImg/".$row_prod['pageImg']."' border='0'><br><br>";
$ret .= "".$row_prod['fld_title']."";
$ret .="<span class='bluttNoBold'>".substr($row_prod['fld_text'], 0, 170)."...</span>";
$ret .= "</td>";
// add an extra <td></td> if there are not enough columns to complete the table
// only test if $i is on the last item of the array
if($i == ($count - 1))
{
// keep adding blank cells till it's at the end
while(($i + 1) % 3 == 0)
{
echo "<td>Tom cell</td>\n";
$i++;
}
}
$ret .="</tr>";
$ret .= "</table>";
$ret .= "<table border='0' cellpadding='0' cellspacing='0' width='160'>";
$ret .= "<tr bgcolor='#BFD634' height='30'>";
$ret .= "<td width='10'><img src='img/gifs/box_downLeftR.gif' height='30' border='0' hspace='0' vspace='0'></td>";
$ret .= "<td width='' background='img/gifs/box_downMiddle.gif' height='30' align='right'><span class='footerOrderSmall'> <a class='footerMenu' href='".$_SERVER["PHP_SELF"]."?action=showPageById&id=".$row_prod['id']."&catId=".$row_prod['pageCatId']."'>".substr($row_prod['fld_title'], 0, 20)." » </a></span></td>";
$ret .= "<td width='10'><img src='img/gifs/box_downRightR.gif' height='30' border='0' hspace='0' vspace='0'></td>";
$ret .= "</table>";
$ret .= "</td>";
return $ret;
}
function window_bottom($itemCatName,$catId,$count,$i) {
// end table row if the remainder of $i+1 divided by 3 is 0
//if(($i + 1) % 3 == 0){
$ret = "</tr>";
$ret .= "</table>";
// }
return $ret;
}
function showProdStart($doId){
global $i,$count;
//$i=0;
$ret = "<table align='center' border='0' cellpadding='0' cellspacing='0' width='510' height='130'>";
$ret .= "<tr><td>";
// ...
//$query_cat = mysql_query("select DISTINCT catId,categoryName from tbl_items inner join tbl_category on tbl_items.itemCatId = tbl_category.catId where tbl_items.itemStat='2' order by tbl_items.itemName AND tbl_items.itemCatId DESC");
$query_cat = mysql_query("select DISTINCT catId,categoryName from tbl_pages inner join tbl_category on tbl_pages.pageCatId = tbl_category.catId where tbl_pages.pageStat='2' ");
while ($row_cat = mysql_fetch_array($query_cat)) {
$ret .= window_top($row_cat['categoryName'],$i);
$query_prod = mysql_query("SELECT * from tbl_pages WHERE pageCatId = '".$row_cat['catId']."' AND pageStat='2' LIMIT 0,6");
while ($row_prod = mysql_fetch_array($query_prod)) {
$count=COUNT($row_prod['id']);
//Puts three kolumns each row
$ret .= window_product($row_prod,$doId,$count,$i);
}
$ret .= window_bottom($row_cat['categoryName'],$row_cat['catId'],$count,$i);
if(($i + 1) % 3 != 0){
$ret .= "</td></tr>fgfgf";
$i=0;
}
$ret .= "</table>";
$i++;
}
echo $ret;
}
MVH mhedda