Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Display records 3 items in a row and move to next row.

FindingAngelsFindingAngels Posts: 1Member
Hi buddies,

I would like to seek help on how to display 3 items in a row and move to next row. I have a short piece of code here and hope someone out there could help me on this.

Let say I have 4 records in database :

$query = "Select * from products";
$result = $db_mysql->query($sql);
while ($row = mysql_fetch_row($result))
for($i=0; i<2; $i++)
[b][color=Red]<? echo $row[id] ?>[/color][/b]


The output display is 1 2 3 4 but I want it to be displayed like this

1 2 3
4 5 6
7 8 9
10 11 12

I would greatly appreciate if someone could help me on this.

Thank you buddies.


  • GabeGabe Posts: 61Member
    For example:
    $query = "Select * from products";
    $result = $db_mysql->query($sql);
    $i = 0;
    while ($row = mysql_fetch_row($result)) {
    if ($i % 3 == 0)
    echo "";
    echo "".$row["id"]."";
Sign In or Register to comment.