• 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

How to execute sql code based on fetch array

How to debug in WooCommerce 3+

how to make my own auto increment in php?

Composer Script echo

How to use functions that are declared in snippets in Evolution CMS (Modx) in an external PHP Script?

PHP7 CLI attempts to load xdebug twice - "Cannot load Xdebug - it was already loaded"

Creating command to backup MySql database in Laravel

browsersync doesn't work with XAMPP

Fatal error: [] operator not supported for strings

How do I pass the dynamic output of a php variable or php function to a CSS variable?

Select option from dropdown menu with PHP and mySql

php echo remove slashes from url [duplicate]

Composer Curl error 60: SSL certificate problem: unable to get local issuer certificate

how to pass row id in href of a tag in codeigniter controller?

PDOException: PDO::__construct(): php_network_getaddresses: getaddrinfo failed: no such host known

About Contact Privacy policy Terms and conditions