• 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

Accessors (Getter) & Mutators (Setter) On a Pivot Table in Laravel

Laravel: Why is my variable not being set while it's in the construct function of the controller?

Exact alternate to mcrypt_encrypt in PHP 7.2

How do I get friend list from Friends table with counts of friends of my friends

PHP Get value from JSON [duplicate]

If action is on a different page do I use fwrite function

Select option menu read from database and use it's values

How do I do HTTP basic authentication using Guzzle?

PHP drop down list using array's and foreach (else and for) code

Laravel 8: Array to string conversion while calling route:list

How to run or debug php on Visual Studio Code (VSCode)

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

Laravel insert dynamic input values with radio button

PHP: PDO + CSV export not downloading (headers issue?)

Laravel database insert with combining array and string

About Contact Privacy policy Terms and conditions