• 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

Warning: Unknown: Failed to write session data using user defined save handler. (session.save_path: ) in Unknown on line 0

Log a user out of a website when they put their computer to sleep

how to identify the web server name of remote host

protect my blog content

unable to load your default controller on Codeigniter

PHP Fatal error: Class not found - PHPUnit

Apply filter array/return terms

Which is faster php date functions or carbon?

How to get company posts from LinkedIn via API?

Laravel Factory not calling callback 'afterCreating'

Display the default discounted price and percentage on Woocommerce products

Maatwebsite Excel 3.1 : how do I skip duplicate data when imported?

Cant seem to get the Pagination to work on my WooCommerce REST API application?

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

XSS attack still works despite htmlspecialchars() doing its work

About Contact Privacy policy Terms and conditions