• 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

Why does codeigniter & Linux server throws unserialize() session data error when user tries to login

How to submit a form when page loads using JavaScript?

How to get an Array value inside an object in an array Php [duplicate]

How to validate Envato Purchase Code in PHP

Unable to create lockable file - Laravel 8 & PHP 8

how to prevent float variables displaying as scientific notation when printing [duplicate]

How to make dot match newline characters using regular expressions

Get WooCommerce products from specific category

Cut an arabic string

PHP Get value from JSON [duplicate]

Laravel 5.1 Unknown database type enum requested

backup files to google drive using PHP

Laravel 8: Array to string conversion while calling route:list

Exact alternate to mcrypt_encrypt in PHP 7.2

Get WooCommerce product variation attribute terms in admin products general box

About Contact Privacy policy Terms and conditions