• 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 use functions that are declared in snippets in Evolution CMS (Modx) in an external PHP Script?

onKeyUp event calculation not working on the following rows from php generated forms except the first one

Laravel print last executed SQL query with Query log

How to make dot match newline characters using regular expressions

How update php.ini on a Mac OS X Mojave?

protect images from being copied

Fatal error: Array callback has to contain indices 0 and 1

Warning: A non-numeric value encountered

Laravel dosen't connect with Oracle

Symfony there are no commands defined in the "make" namespace

Why "Class 'GuzzleHttpClient' not found" even after Installing it in Laravel?

I want a way to give path to my files which are outside of public folder in laravel

how to remove white space in select 2

Get lat/lon from google maps url ftid (hex)

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

About Contact Privacy policy Terms and conditions