• 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

Log a user out of a website when they put their computer to sleep

insert multiple rows in a saveall in cakephp

xdebug 3 not working in ubuntu 20.04 with docker

MySQL upgrade causing unexpected results on simple WHERE clauses

IlluminateDatabaseQueryException could not find driver [duplicate]

I cannot create a auto generated date time in mysql workbench

Add New Parameter to Existing URL using htaccess

How do I enable error reporting in Laravel?

PHP using str_starts_with for array to exclude same as with wildcard

PHP cURL (SSL certificate problem: self signed certificate in certificate chain)

WordPress + Nginx on non-standard port behind AWS ELB results in broken links

Passing PHP JSON to Javascript: echo json_encode vs echo json declaration

Symfony 4: how to allow dynamic values for array nodes in bundle configuration?

Pass a select with mysqli_fetch_row to a table

could not find driver Debian SQL Server PHP

About Contact Privacy policy Terms and conditions