• 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

"Notice: Undefined variable", "Notice: Undefined index", "Warning: Undefined array key", and "Notice: Undefined offset" using PHP

Symfony/Form add attribute based on the data

Using if(isset($_POST['submit'])) to not display echo when script is open is not working

XAMPP keeps showing Dashboard/Welcome Page instead of the Configuration Page

How can I solve "laravel/horizon v1.1.0 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system"?

Laravel : How to Create Dropdown to Select FOREIGN KEY from Other Table?

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

Ajax GET request fails in laravel 8

No definition found for function in vendor vscode

Destroy session upon refresh

php code to send checkbox form results to email

Correct way to use LIKE '%{$var}%' with prepared statements?

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

301 Redirect to remove query string on homepage only

Show Custom Data in Woocommerce Order Details Admin Area

About Contact Privacy policy Terms and conditions