Explore the Premium Content

PHP Graphing: Pie Charts Coloured and Exploded

In the continuing series of dynamically drawing graphs with the PHP image functions, this week we revisit our pie graph and look at how to fill it with colour, and then how to give them an "exploded" look.  As in most things with programming, there is more than one way to skin a cat, so we'll also take a look an alternate method of drawing the wedges of our pie chart.

It'll look much like this:

Read More

Validating Forms with ASP.NET Validator Controls

This tutorial will explain how to correctly use the Validation server controls built into the .NET Framework to validate user input on your pages. We begin by defining what validation is and the differences between client side and server side validation. Complete working examples of each of the validation controls are provided as well as solutions to some of the common problems that arise when using the Validator controls, including how to implement validation groups. These can be used for submitting different sets of validated fields separate from other sets of validated fields whilst only validating the set of fields being submitted.

Read More

PHP Graphing – Pie Charts

We've built up a bar chart script, and now we draw a pie chart.

Drawing a pie chart is more complex than drawing a bar chart.  We will need to create a script that takes the data from the data holding class and convert it into proportional amounts.  With line and bar charts we were simply plotting a value along the vertical axis and the series along the horizontal axis, but with a pie chart, all of the data is represented in a circle.  This means that we will need to work out proportionately how much each of our plot values will take up of the 360° that makes up a full circle.  Once we have worked out the proportional amounts, we will then have to use some maths to determine where and how to draw the wedges of the circle that will represent the data.  Read More

PHP Custom Web Statistics – Part 2

In the second part of this tutorial about creating your own custom web statistics, we analyse the data that is collected each time a page is viewed. We'll be looking at various ways of reading the data we require from the database, and making MySQL work harder by using some of its extra functions to process our data.

We create a function to execute an SQL query, so that we don't repeatedly enter code to open and close the database etc, which makes for shorter code that’s easier to understand and debug. We then create a range of functions that could extract certain statistics from the data stored in the database. We create a set of functions which create the SQL queries dynamically, and can be easily inserted into the framework of the main site pages.

We then construct a page which serves as the index page for the web statistics application, and shows an overall view of every year that has data in the database, showing each year and the number of hits per month.

Finally, we create a page that displays a single year's-worth of data at a time, in a table which is dynamically generated using PHP, and shows more detailed figures for the year.

 

Please note that this article forms part of a chapter in the DMXzone e-book PHP Web Applications for Dreamweaver: Juicy Solutions for the Busy Developer.

 

Read More

Using Server Behaviours – Good or Bad?

Today we’re going to look at Dreamweaver’s ASP Server Behaviours (hereafter SBs). We’ll make use of them to display some data, step by step, and analyse how quick and easy it was to do. We’ll have a look at what happens when we try to take it a step further. Once we realise that the SBs merely provide a starting point, we’ll apply some code by hand to increase the usefulness of our page.
 
Finally, once we have seen both the use of SBs and hand-typed code, we’ll explore the advantages and disadvantages of each. I hope to demonstrate that although SBs are useful, they are quite limited, and that learning to code by hand will provide immense benefits over SBs, both in terms of possibility and performance. Read More

Graphing: dynamic 3D bar charts

In today's article on dynamic graphing with PHP, we convert the supplied script that plots a a line graph into one that plots a bar chart on the fly from dynamic data:



Then, we discover how to fill the bars with colour:


Finally, we give the bars a 3D perspective effect:


The start-up code is provided, so the tutorial is for Dreamweaver users with any level of PHP experience.

Read More

Using System.Data.DataSet Part 2

This stand-alone article expands upon the previous article by showing you how to populate a DataTable with other types of Data and how to programmatically insert DataTables into a DataSet.  We also cover the DataTable class's Expression property and its Compute method, which make calculating totals from your data much easier. Finally we will see how to save DataSet contents to XML files and then load the XML Data back into a DataSet -  a very handy feature when you need to transfer DataSets to another computer, or the same computer at a later date whilst preserving the Dataset’s structure and data.
 
The following topics are covered in this article:
 
  • Populating a DataTable with other types of Data
  • Programmatically Inserting the DataTable into a DataSet
  • An introduction to the DataColumn class
  • The DataTable Compute method
  • Saving DataSet Data as XML Data
  • Reloading Saved XML Data into a DataSet
Read More

Graphing with PHP: Line Graphs

In our tutorial last week, Graphing with PHP, we started building a class that you could use to draw a graph using the PHP Image functions.

We used a simple data holding object that contained all of the data that we needed to draw our graph, and then passed that to a graph drawing script by storing the data temporarily in a Session variable on the server. This method allowed us to use our PHP image drawing scripts as the SRC of an IMG tag so that the dynamic graphics could be embedded within an HTML page.
 
At the moment, our class just plots asterisks, so the first thing that we will need to do is change our graph from drawing in asterisk characters for the plot points, to using an actual line. It's helpful to have read the last tutorial, but all the code is supplied for download to allow you to product dynamically-generated line graphs on the fly from PHP. Read More

ASP and Forms: The Request object

We're going to build a form for a website that will automatically email the form's contents to one of a range of email addresses, depending on a radio button selected by the user. I show you how to build this using Dreamweaver MX 2004, and supply the ASP code, and then we examine it to learn how it works. We examine the differences between the GET and POST methods, server-side valiadtion of the form - and when client-side validation with JavaScript is better.



This tutorial uses DMX 2004 for screenshots, but will work unchanged in DMX.

Read More

PHP Custom Web Statistics

Keeping logs of who visits your site is useful as it allows you to see how many people are visiting your site, and which pages are the most popular and most frequently visited. Pages which have low visitor numbers can then be changed to make them more appealing. Alternatively, it may turn out that your navigation system isn't working as well as it could be, and you can then change it to make the pages with low numbers of visitors easier to find.

Creating your own system using PHP and MySQL means that you can still have detailed statistics about who visits your site, even if your web host doesn't allow access to the server log files. It also means that you can create your own custom reports to show the data that is of most interest to you, rather than being locked into the standard reports that many web hosts provide.

  • In this first tutorial of the series, we first look at how to obtain information about visitors to your web site such as the users ip address and information about the users browser and operating system from the special PHP $_SERVER array.
  • We then create an include file containing the MySQL database connection parameters which can be added to any page that requires access to a MySQL database. This gives us the advantage that if the MySQL server is changed in the future, then the new connection parameters only need to be changed once in the include file rather than on every page that uses the MySQL database.
  • Then we create another include file that can be easily added to any web page that you want to log, and writes details about the web page visitor to a MySQL database table ready to be analysedata later date.

 

Please note that this article forms part of a chapter in the DMXzone e-book PHP Web Applications for Dreamweaver: Juicy Solutions for the Busy Developer.

 

Read More

Graphing with PHP

In this and next weeks’ tutorials we will be building on what we have covered by developing a set of basic objects that you can use for drawing graphs from dynamic data. After all, what use is having these great tools for drawing graphs and charts if you can't draw them dynamically? If that were the case you may as well stick to using Macromedia Fireworks or exporting a graph from Microsoft Excel.
 
We'll build up a PHP script that implements a graph object. We’ll start simple and explain the whys and wherefores as we go along – don’t worry of you missed the previous two articles as we'll do some quick revision as we go along.

Today we:
  1. create  a script that implements a class to store all of our graph data. 
  2. We will instantiate the object in our main script and give it all the information about our graph. 
  3. Once we have all of the data in place we will then write out our image tag. 
  4. As that happens we will save the entire object into a session variable and pass an identifier to that session variable to the graph drawing script.
  5. The graph drawing script will then access the graph data object through the session variable and draw the graph accordingly.

This tutorial contains some maths, but the code is provided and is suitable for intermediate PHP developers using either Dreamweaver MX or MX 2004.

Read More

Using System.Data.DataSet Part 1

This article which is the first in a two article series will serve as an introduction to the System.Data.DataSet class and how it can be used to work with database data. It is important for Dreamweaver users to realize that this class is not the same as the DreamweaverCtrls.DataSet used by Dreamweaver but is in fact a built-in feature of the .NET Framework. The System.Data.DataSet and is far more flexible and feature rich than the DreamweaverCtrls DataSet.
 
The following topics will be covered during the course of this article:

  • An Introduction to System.Data.DataSet
  • The Difference between System.Data.DataSet and DreamweaverCtrls.DataSet
  • Populating a DataSet with Database data
  • An introduction to the DataTable class
  • Using Multiple Tables with Relations
Read More
Newer articles Older articles