• 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

Querying only one row from a one to many relationship laravel

I want to store data in new index as per my key in php [duplicate]

dompdf and img tag, image wont show

Is there a way to correctly use sanitize_text_field and wp_unslash that doesn't cause psalm to error with "expects string, possibly different type"

PHP Fatal error: Class not found - PHPUnit

How to disable only_full_group_by option in Laravel

How do I do HTTP basic authentication using Guzzle?

Converting IPv6 to IPv4 address in PHP

Elasticsearch - Want to sort by field in all indices where that particular field available or not if not then avoid it

PHPExcel export HTML table to xlsx

PHP echo values of all sub keys [duplicate]

PHP: How to raise number to (tiny) fractional exponent?

Laravel 5 controller sending JSON integer as string

How do I truncate a decimal in PHP?

sort() not affecting original array while inside foreach loop

About Contact Privacy policy Terms and conditions