• 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

Limit login attempts in Laravel 5.7

Display a product custom field only in WooCommerce Admin single orders

Sliders in Laravel

Dropdown with current value from Mysql

Fatal error: Trait 'LaminasDbAdapterLaminasDbAdapterAdapterInterface' not found in /var/www/vendor/laminas/laminas-db/src/Adapter/Adapter.php

How to pass data to all views in Laravel 5?

Upload a file Using PHP and JavaScript

Woocommerce product attributes with hierarchy like categories

The "client_reference_id" argument is not passed

How to use React Router with Laravel?

how to see if database exists with PDO [duplicate]

How to create custom authentication in laravel 8?

WAMP/Wordpress - cURL error 28: Operation timed out after 10001 milliseconds with 0 bytes received

Laravel/docker-compose/redis - Class 'Redis' not found

Handle error for duplicate entries - PHP/MySQL

About Contact Privacy policy Terms and conditions