• 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

Laravel views are showing from cache on one server but works fine on other server

Wordpress 'post_type_link' hides permalink

NGINX: connect() to unix:/var/run/php7.2-fpm.sock failed (2: No such file or directory)

SendGrid: Sending an email to multiple recipients without other emails being shown on the "to" field

Center point of multiple gps coordinates with php

SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: 'column_name' in Laravel

Show Custom Data in Woocommerce Order Details Admin Area

Using PHP to connect to a remote MSSQL database

Symfony Make:Migration : The metadata storage is not up to date, please run the sync-metadata-storage command to fix this issue

add uri parameter to Route name in laravel

Laravel 4 Redirect::back() not going to previous page (refreshing current page)

How to install php_imagick on wamp64

Select option from dropdown menu with PHP and mySql

PHP-Sort array based on another array?

Convert regular text to array using notepad++

About Contact Privacy policy Terms and conditions