• 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 5 issue with wherePivot

PDOException: PDO::__construct(): php_network_getaddresses: getaddrinfo failed: no such host known

Post Form Data To phpmyadmin Database

correct PHP headers for pdf file download

wordpress function breaks wp-admin

How to programmatically find public properties of a class from inside one of it's methods

Add New Parameter to Existing URL using htaccess

laravel 5.6 bulk inserting json data

curl returning 301 error after migrating to https

How to break out of a foreach once a condition is met?

Xdebug can't connect back to Docker host

How to pass security cloudflare server with php curl

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

GA4 custom event from server side, can someone tell me how i can do the following code in php?

how to insert data into select2 search input after scan using qrcode

About Contact Privacy policy Terms and conditions