• 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 assert parameter attribute sub-structures in PHPUnit mock call expectations

PDOException SQLSTATE[HY000] [2002] No such file or directory

PHP function Not Working As Expected From functions.php Include File

Detect if PHP session exists

How to create laravel storage symbolic link for production or sub domain system?

stay with the last 15 elements of an array [duplicate]

How can I get data from PHP to Android TextView?

Issue with laravel eloquent model property

Store / Website Column in Magento 2 Admin Grid - Custom Module

Xdebug 3 not showing in phpinfo on m1 Monterey

Laravel no logout option from menu after successfull login

Laravel UUID generation

Dynamic table in HTML using MySQL and php

oauth-private.key does not exist or is not readable

How to get array values using foreach in laravel

About Contact Privacy policy Terms and conditions