• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

Mysqli Output to a table

phpmysqlmysqli


PHP Snippet 1:

$requiredRows= 18; 
$rows = $result->num_rows ;
$columns = ceil($rows/$requiredRows);
$i = 0;
while($row = $result->fetch_assoc()) 
    {
    if ($i == 0) {
        echo "<table><tr><td>";
    }
    elseif ($i % $columns) {// <> 0
        echo "</td>\n";
        echo "<td>\n";
    }else{//$i % $columns == 0
        echo "</td>\n";
        echo "</tr>\n";
        echo "<tr>\n";
        echo "<td>\n";
    }
    echo $row['country'];
    $i++;
}

Related Snippets

How to set a domain name with php artisan serve

How to display MySQL table using php and edit it in a web browser

Open a popup box after receiving result from ajax

Eloquent insert id with sequence next value

WordPress Security Standards want me to escape my html, but how to do it correctly?

Move a child array to parent array and change parent/child name

How to get array values using foreach in laravel

How can I easily switch between PHP versions on Mac OSX?

PHP date() with timezone?

How to send image,audio or video through the WhatsApp API - PHP

Target Laravelista is not instantiable

Upload a file Using PHP and JavaScript

image source not readable

How to get total pages of PDF with FPDF?

IlluminateDatabaseQueryException: SQLSTATE[HY000]: General error: 1 no such table - In clone project

About Contact Privacy policy Terms and conditions