WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search


Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - השוואת מחירים בסופר
ZeroLag.com
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : How to display any array in several rows and columns of a table. Not just in one column or in alternate rows. This example shows a nice color table generated with PHP, but can be used with any array values(e.g. Database)
Categories : Arrays, PHP, Miscellaneous, Beginner Guides, Graphics Update Picture
Andy Krause
Date : Dec 14th 2000
Grade : 2 of 5 (graded 12 times)
Viewed : 31676
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Andy Krause
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

On each and every corner you find snippets on how to display every second row e.g. in a
different color. But what, if you want to display a table with 6 rows and 6 colums in different
colors? Here's the solution:

<?
$colors=ARRAY(
"#000000","#000033","#000066","#000099","#0000CC","#0000FF","#003300",
"#003333","#003366","#003399","#0033CC","#0033FF","#006600","#006633",
"#006666","#006699","#0066CC","#0066FF","#009900","#009933","#009966",
"#009999","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99",
"#00CCCC","#00CCFF","#00FF00","#00FF33","#00FF66","#00FF99","#00FFCC",
"#00FFFF");
?>

<table border="0" cellspacing="1" cellpadding="0">
<tr>
<?
for($i=0; $i< count($colors); $i++) {
echo '<td>
<table name="'.$colors[$i].'" width=10 height=10 border="0" bgcolor="'.$colors[$i].'">
        <tr>
<td><img src="_blank.gif" width="1" height="1" border="0" alt=""></td>
        </tr>
</table>
</td>';

if ( (($i+1) % 6) == 0 ) echo $newrow="</tr><tr>"; // change 6 to 8 and see
}

?>                
</tr>
</table>


If you replace the array of colors with any database generated value, you can generate a
table of images like an album nicely without manually fiddling with the code.

Enjoy and let me know, if it helps.

n-dee



Selecting a random line from a text file
Categories : PHP, Filesystem, Arrays, Beginner Guides
Beginners Array Functions
Categories : PHP, Beginner Guides, Arrays
PHP Email image generator - hide your email from bots - using the GD Library
Categories : PHP, Graphics, GD image library, Beginner Guides
HTML_Graphs uses PHP to provide a consistent interface for creating HTML based charts. The user of the class sets up arrays that are passed to html_graph() which then takes care of all the messy HTML layout.
Categories : Graphics, Arrays, PHP, PHP Classes, Charts and Graphs
Simple PHP Bar Graph using GD library
Categories : PHP, GD image library, Graphics, Arrays
Human readable PHP password generator
Categories : PHP, Security, Beginner Guides, Arrays
Random text quote
Categories : PHP, Arrays, Beginner Guides
Simple image counter
Categories : PHP, Graphics, Filesystem, Beginner Guides
This script will read all images from a folder and read the files into an array. It uses rand() to get a random number. It will display a random image from the image folder given.
Categories : PHP, Arrays, Graphics, Filesystem
Form Submission Using Array's
Categories : PHP, HTML and PHP, Beginner Guides, Arrays
Simple way of scaling any image to fit either given width or height.
Categories : PHP, Graphics, Arrays
PHP Image Validation Class - test if a specific file is of a certain image type without relying on the said file extension.
Categories : PHP, PHP Classes, Data Validation, Graphics, Beginner Guides
Using PHP im HTML image tags
Categories : PHP, HTML and PHP, Graphics, Beginner Guides
Link Submition - Allow your visitors to submit links to the site.
Categories : PHP, Arrays, Filesystem, Beginner Guides
crop and resize image class using gd library function
Categories : PHP, PHP Classes, GD image library, Graphics