• 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

Inserting Country Selection into MySQL PHP [duplicate]

How to get transaction details in notify_url page in paypal

PHP - Store information with NO database

PHP Slim Framework request using withAttribute error

How to convert time from one timezone to another in PHP

How to prevent phpmailer sending embedded image as an attachment on Gmail?

Warning: mysqli_stmt::bind_param(): Number of elements in type definition string doesn't match number of bind variables 11 [closed]

Unable to match results of php hash_hmac() and coldfusion hmac()

Transpose and flatten multiple rows of array data [duplicate]

CONCAT columns with Laravel 5 eloquent

How to KeyBy where multiple items have the same key

PHP mail function is sending blank message body

Limit login attempts in Laravel 5.7

How do I truncate a decimal in PHP?

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'name' cannot be null

About Contact Privacy policy Terms and conditions