• 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

Override default Auth routes in Laravel 7

"There is no active transaction" when refreshing database in Laravel 8.0 test

php script to delete files older than 24 hrs, deletes all files

Where do I need to place a hook for phpunit?

shell errors running php exec

How Can I Do LIMIT 1, 2 In WP_Query

wordpress : How to specify the cause "This site can’t be reached"

I cannot create a auto generated date time in mysql workbench

GuzzleHttp Hangs When Using Localhost

How to solve Duplicate entry '0' for key 'PRIMARY' in Wordpress?

Getting error: CodeIgniterDatabaseBaseResult::getResult in CodeIgniter

Elasticsearch - Want to sort by field in all indices where that particular field available or not if not then avoid it

Issue saving card for customer

Add customer email and phone in "Order" column to admin orders list on Woocommerce

"Unable to load dynamic library 'pdo_sqlsrv.so' "Cenos7 PHP7.2.10

About Contact Privacy policy Terms and conditions