Jump to content

Archived

This topic is now archived and is closed to further replies.

adyre

Multiple Column display results

Recommended Posts

I have thisd code:

<?
if(!empty($_GET['cat']))
{
$td = 3;
$tr = 10;

$total = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM subcat WHERE id_cat='".$_GET['cat']."'"),0) or die (mysql_error());
if($total == 0){
print "Nu exista inregistrari!";
}
elseif(!isset($_GET['pag'])){
$pag =1;
}
else{
$pag = $_GET['pag'];
}

$sql = mysql_query("SELECT * FROM subcat WHERE id_cat='".$_GET['cat']."' ORDER by nume ASC limit ".(($pag * ($td * $tr)) - ($tr * $td)).",".($tr * $td)." ") or die (mysql_error());

$pag_total = ceil($total/($tr * $td));

if($pag > $pag_total){
print "Nu exista inregistrari!";
}
elseif($pag_total > 0) {
$settd=0;
?>
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<?
while($row = mysql_fetch_array($sql)){
if($settd == $td) {
print "</tr><tr>\n";
$settd=0;
}
elseif($settd != $td) {
$settd++;
?>
<td align="center" valign="middle"><?=$row['id']?> - <?=$row['nume']?></td>
<?
}
}
}
print "</tr></table>";
}
?>


Problem: It show from database all without a row.

If I remove:
<?
elseif($settd != $td) {
$settd++;
?>
<td align="center" valign="middle"><?=$row['id']?> - <?=$row['nume']?></td>
<?
}
?>

it show's all my rows, but ofcourse it doesen't show's me the results on columns.

Any other ideea...

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.