• 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

Laravel after login Two factor not working

target [LaravelFortifyContractsRegisterViewResponse] is not instantiable

How should I get started using PHPUnit as a testing framework for a bunch of functions and classes I have already made?

Not able to access model in the controller mautic

Combining a describing and one array with data

How to find phpcs current default standard

I'm trying to write a clean url for my website using the $_SERVER['REQUEST_URI'] in php

PHP, how to convert Int value to Week days

Timber: Single post pagination does not work (wp_link_pages)

How to show selected value using javascript in laravel

Error converting docx to pdf using Unoconv

php - add comma thousands separator but remove trailing zeros

Yii2: How do I debug console commands?

jQuery Ajax Post with data

LARAVEL: How to fetch id dynamically in a query builder?

About Contact Privacy policy Terms and conditions