• 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

PHP array, move keys and values to new array, but mix it up

Exception thrown during the rendering of a template("Parameter "id" for route "url" must match "[^/]++" ("" given) to generate a corresponding URL.")

How to get unique slug to same post-title for other time too?

PHPMetrics option --excluded-dirs="myfolder" : myfolder dir is not excluded within docker

Center point of multiple gps coordinates with php

get folder directory from input type file - PHP

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

Currently Using CodeIgniter Framework i have an Error

Symfony Mercure "Failed to send an update"

How to skip cart page on woocomerce for certain products only?

Open a popup box after receiving result from ajax

Problems getting instance of UploadedFile in Yii2

Limit WooCommerce products in cart only from one custom taxonomy

Creating a config file in PHP

Symfony 4: "Autowire: you should configure its value explicitly."

About Contact Privacy policy Terms and conditions