• 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

phpseclib 2.0 can not use Composer to create autoload

Download & Save Zoom Recording in directory by PHP

Magento 2 - How to add new block to admin panel in product page?

how to remove %20 in the url in php

php file upload scanning using clamav, permissions on /tmp/

PHP only Hit Counter?

How to retrieve Active Directory group policy maximum password age using LDAP

Server-sent events in PHP (without echo or print)

I want to display a sweetalert after the inserting of data in my database

Object of class stdClass could not be converted to string error

add uri parameter to Route name in laravel

Convert every two values of an associative array into key-value pairs

XAMPP/SQLSRV: Unable to find Sqlsrv in PHPINFO(); - errors coming from connection

Merge column values from two arrays to form an indexed array of associative arrays

LARAVEL: How to fetch id dynamically in a query builder?

About Contact Privacy policy Terms and conditions