SunQuest
 
       PHP
  Home arrow PHP arrow Page 5 - Making Usage Statistics in PHP
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Actuate Whitepapers 
VeriSign Whitepapers 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Making Usage Statistics in PHP
By: Adam Szanto
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 108
    2004-02-16

    Table of Contents:
  • Making Usage Statistics in PHP
  • Save the HTML Title
  • Showing the Statistics Table
  • Showing Figures Based on the Statistics
  • Creating the Image Library
  • Charting the Results
  • Before Saying Goodbye

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Making Usage Statistics in PHP - Creating the Image Library


    (Page 5 of 7 )

    Having the data, let's start to deal with the image creation library of PHP (GD). Its output is GIF/PNG/JPEG. It uses image resources.  These are PHP variables representing images. Usually, in a program there is only one image resource. You can create an image resource using one of the following functions:

    1. ImageCreate (int width, int height) - Creates a blank image resource
    2. ImageCreateTrueColor (int width, int height) - Creates a blank true color image resource
    3. ImageCreateFromGIF (string filename) - Creates an image resource using a given picture file
    4. ImageCreateFromJPEG (string filename) - Creates an image resource using a given picture file
    5. ImageCreateFromPNG (string filename) - Creates an image resource using a given picture file

    This code can be good for this, but don't forget to call the header function because it's not HTML output!


    header('Content-type: image/png');
    $image
    =imagecreate(400,210); 

    Then you can start to draw the picture. Here are some of the functions - read them as we will use some to make the Top 10 stats. For more, see the PHP manual.

    1. ImageColorAllocate (resource image, int red, int green, int blue) - Prepares an RGB color to use
    2. ImageLine (resource image, int x1, int y1, int x2, int y2, int color) - Draws a line
    3. ImageRectangle (resource image, int x1, int y1, int x2, int y2, int col) - Draws a rectangle
    4. ImagePolygon (resource image, array points, int num_points, int color) - Draws a polygon using an array
    5. ImageFilledRectangle (resource image, int x1, int y1, int x2, int y2, int color) - Draws a filled rectangle
    6. ImageTTFText (resource image, int size, int angle, int x, int y, int color, string fontfile, string text) - Draws a TrueType text

    Below you can read the code. It can be a little confusing, especially the numeric expressions, because you have to think in X and Y coordinates. But try it, you'll get the hang of it!

    More PHP Articles
    More By Adam Szanto


     

    PHP ARTICLES

    - Making Usage Statistics in PHP
    - Installing PHP under Windows: Further Config...
    - File Version Management in PHP
    - Statistical View of Data in a Clustered Bar ...
    - Creating a Multi-File Upload Script in PHP
    - Executing Microsoft SQL Server Stored Proced...
    - Code 10x More Efficiently Using Data Access ...
    - A Few Tips for Speeding Up PHP Code
    - The Modular Web Page
    - Quick E-Commerce with PHP and PayPal
    - Regression Testing With JMeter
    - Building an Iterator with PHP
    - PHP Frontend to ImageMagick
    - Using PEAR's mimeDecode Module
    - Incoming Mail and PHP







    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway