• 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

HTTP Range requests with php for Video Embedding for solving going to specific time in video (seek bar not work)

phpmyadmin : Depends: php-twig (>= 2.9) but 2.6.2-2 is to be installed. WHAT?

How to validate tin and cst using PHP?

Respond with status code 401 on authentication failure using Laravel and Passport?

Elastic Beanstalk with Laravel Envoy

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

PHP random string generator

how to get the header value, if we don't know the value because the value is random from the server

PHP - installing Xdebug on Mac with XAMPP (Unix File)

Execute only one time and then wait set period of time before executing again

Transform array, set each array element with parent key php

Sort multidimensional array by column value within a column

How to convert time from one timezone to another in PHP

Using Associative arrays

How to Create WooCommerce Subscription Product via. REST API?

About Contact Privacy policy Terms and conditions