I want to display records from database in this order
1 2 3
4 5 6
........
or
1 4 ....
2 5 ...
3 6.....
pls can anybody help me ........
I want to display records from database in this order
1 2 3
4 5 6
........
or
1 4 ....
2 5 ...
3 6.....
pls can anybody help me ........
I want to display records from database in this order
1 2 3
4 5 6
........
or
1 4 ....
2 5 ...
3 6.....pls can anybody help me ........
Not much use putting that info in this solved topic. Try setting up a new topic.
<?php while ($prows = mysql_fetch_array($rs_pending)) {?>
<tr>
<td>#<?php echo $prows['id']?></td>
<td><?php echo $prows['NameOfCompany']?></td>
<td><?php echo $prows['emailId']?></td>
<td><?php echo $prows['Category']?></td>
<td><?php echo $prows['Activity']?></td>
<td><?php echo $prows['Address']?></td>
<td><?php echo $prows['Phone']?></td>
<td><?php echo $prows['Fax']?></td>
<td><?php echo $prows['Website']?></td>
</tr>
<?php } ?>
this will display records in this order normally
1
2
3
.
.
But my query is i want 2 display records in this order..
1 2 3
4 5 6
.........
or
1 4 . . .
2 5 . . .
3 6. . .
pls anybody help me...if u any idea r code send it.....
3
a simple solution to this can be to use a counter for ur loop and check to introduce a new <tr> when its in multiples of 3(or 2 watever the num of columns u r lookin for).
something like this...
<?php $counter =0;
while ($prows = mysql_fetch_array($rs_pending)) {
if (($counter%3) == 0)){ ?>
<tr>
<?php } ?>
<td><?php echo $prows['id']?></td>
<td><?php echo $prows['NameOfCompany']?></td>
<td><?php echo $prows['emailId']?></td>
<td><?php echo $prows['Category']?></td>
<td><?php echo $prows['Activity']?></td>
<td><?php echo $prows['Address']?></td>
<td><?php echo $prows['Phone']?></td>
<td><?php echo $prows['Fax']?></td>
<td><?php echo $prows['Website']?></td>
if (($counter%3) == 0)){ ?>
</tr>
<?php } ?>
<?php $counter++; } ?>
<?php while ($prows = mysql_fetch_array($rs_pending)) {?>
<tr>
<td>#<?php echo $prows?></td>
<td><?php echo $prows?></td>
<td><?php echo $prows?></td>
<td><?php echo $prows?></td>
<td><?php echo $prows?></td>
<td><?php echo $prows?></td>
<td><?php echo $prows?></td>
<td><?php echo $prows?></td>
<td><?php echo $prows?></td>
</tr>
<?php } ?>
this will display records in this order normally
1
2
3
.
.
But my query is i want 2 display records in this order..1 2 3
4 5 6
.........or
1 4 . . .
2 5 . . .
3 6. . .
pls anybody help me...if u any idea r code send it.....
3
open up a new thread if u face some problems, no 1 is going to reply here anymore..
This thread is already solved
Following code is for 3 columns and n no of rows. it will print you ID as
1 2 3
4 5 6
....
<?php
$isrowopen=false;
$totalrows=0;
while ($prows = mysql_fetch_array($rs_pending))
{
$totalrows++;
if((($totalrows)%3)==1)
{
print "\n<tr>";
$isrowopen=true;
}
?>
<td>#<?php echo $prows['id']?></td>
<?php
if((($totalrows)%3)==0)
{
print "\n</tr>";
$isrowopen=false;
}
}
if ($isrowopen && (($totalrows)%3)==1)
print "\n\t\t<td> </td><td> </td></tr>";
else if ($isrowopen && (($totalrows)%3)==2)
print "\n\t\t<td> </td></tr>";
?>
Following code is for 3 columns and n no of rows. it will print you ID as
1 2 3
4 5 6
....<?php $isrowopen=false; $totalrows=0; while ($prows = mysql_fetch_array($rs_pending)) { $totalrows++; if((($totalrows)%3)==1) { print "\n<tr>"; $isrowopen=true; } ?> <td>#<?php echo $prows['id']?></td> <?php if((($totalrows)%3)==0) { print "\n</tr>"; $isrowopen=false; } } if ($isrowopen && (($totalrows)%3)==1) print "\n\t\t<td> </td><td> </td></tr>"; else if ($isrowopen && (($totalrows)%3)==2) print "\n\t\t<td> </td></tr>"; ?>
tanhx.......I appreciate..
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.