• 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 write PHP in XSLT

Laravel - Implicit route model binding with soft deleted data

Stop caching for PHP 5.5.3 in MAMP

PHPExcel file download using AJAX call

Laravel whole batch is cancelled if one Job fails

GRPC installed successfully on ubuntu but php is looking for it in another folder

Installing Composer - Internal Error

Sentry on Symfony: how to exclude `NotFoundHttpException`

Laravel Route issues with Route order in web.php

phpseclib 2.0 can not use Composer to create autoload

Insert And Retrieve Data in MySQL with $.post Noob Question

How to implement placeholder in a php file for moodle plugin?

How to validate Envato Purchase Code in PHP

WooCommerce Additional Information - if empty, hide

Use same method for inertia response and json response Laravel Jetstream

About Contact Privacy policy Terms and conditions