• 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

How to get the total hour from starting time to end time in php

Google API Heatmap Layer exception, why?

Get latest Tweets - What API

PHP: Telegram Bot: Insert line break to text message

How can I make good efficent AJAX live forms with just jQuery and

I want to display a sweetalert after the inserting of data in my database

How do I truncate a decimal in PHP?

PHP header location absolute URL

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

PHP file_get_contents function

What is the difference between client-side and server-side programming?

Redis Command To Sort Keys

How to increase the PHP upload limits [duplicate]

PHP Find Array Index value in multi-line array

Insert a DIV after the 6th product only once in WooCommerce category archives

About Contact Privacy policy Terms and conditions