Jump to content

Multiple Column display results


adyre

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...
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.