qingsuanhy |
Wysłany: Nie 9:02, 30 Sty 2011 Temat postu: spyder jacket Statistical View of Data in a Cluste |
|
The inner-most loop iterates through every student��s name.? It calls the function Collect_Data(..) and stores it in five arrays:??? $student_name[], $program[], $subject[], $student_data[], and $student_dt.? It too stores their amount in variable $sum.? From dividing $student_data along $sum, we can calculate the ratio. The length of the picture is determined according to this percentile.? Also, an smart code is used to draw a new bar each period.? Then, using this file, it draws the bar chart whereupon. Display the information in tabular format at iterating and retrieving data from the on 5 arrays. Third part terminates the table. This part purges the on 5 arrays. This is important in that whether array size is smaller in the afterward iteration, the before data may be written.
<select name="sel_month_from">
<?php
for ($i = 1; $i < 10 ; $i++)
echo "<option value=0".$i.">" . $months[$i] . "</option>";
for ($i = 10; $i < 13; $i++)
echo "<option value=".$i.">" . $months[$i] . "</option>";
php?>
</select>
Processing time is calculated based on the retinue code:
If both dates are correct, then range of the date is stored in the $msg variable.
The processing code is mobilized in such a course that it needs 3 laired FOR loops.? You can mushroom alternatively dwindle them apt add/drop a new dimension.
for ($c=0; $c < $total_counts_program_id; $c++)
{
for ($b=0; $b < $total_counts_subject_id; $b++)
{
// Collection of Data
for ($a=0; $a < $total_counts_student_id; $a++)
Collect_Data($sel_id[$a] , $sel_program_id[$c] , $sel_subject_id[$b]);
// end of the sel_id loop
$total_counts_student_id = count($sel_id);??
$total_counts_program_id = count($sel_program_id);??
$total_counts_subject_id = count($sel_subject_id);
The above variables have been affirmed global so that their values can be accessed outdoor this consumer defined function; otherwise, they would convert regional variables, thus rendering them out of range.
if ($sum > 0)? // if data found? ...
{???
// Draw Graph????????????
$total_counts = count($student_data);
for ($i=0; $i < $total_counts; $i++)
???
$bar_width = multi_factor * ( (100 * $student_data[$i] ) / $sum );?????
$bar = ($i % bar_counter)."_bar.gif";??
echo "<tr><td><img src='images/$bar' width=$bar_width? height='10'>?? ";
echo number_format($bar_width/multi_factor , 2, '.', '')."%??? (".$student_name[$i] . " , " . $program[$i] . " , " . $subject[$i] . ")</td></tr>";? ??
// Display Data in Tabular Format???
echo "<tr><td><table border=1 bordercolor=blue>";
echo "<tr><th>Name</th><th>Program</th><th>Subject</th> <th>Marks</th><th>Date</th></tr>";
for ($i = 0; $i < $total_counts; $i++)
{
echo "<tr><td>" . $student_name[$i] . "</td><td>" . $program[$i] . "</td><td>" . $subject[$i] . "</td>";
if (isset($student_data[$i]) )? echo "<td>" . $student_data[$i] . "</td>";
another??????????????????????????? echo "<td>Not Taken</td>";
echo "<td>" . formate_date($student_dt[$i]) . "</td></tr>";
}
echo "</table></td></tr>";??? $x = 0; $sum = 0;? echo "<tr><td><hr></td></tr>";?
for ($i=0; $i < $total_counts; $i++)? /// purge the array ... better to purge all the arrays.....
array_pop($student_data);
<?php
$months = array (1=>"January" ,spyder jacket, "February" , "March" , "April" , "May" , "June" , "July" , "August" , "September" , "October" , "November" , "December");
php?>
$dt_from = $sel_year_from . $sel_month_from . $sel_day_from;
$dt_to?? = $sel_year_to . $sel_month_to . $sel_day_to;
$dt_valid = "False";
$back = "<a rel="nofollow" onclick="javascript:_gaq.push(['_trackPageview',cheap Alife shoe, '/outgoing/article_exit_link']);" href="" onclick="history.back()">Back</a>";
if ( !(checkdate(intval($sel_month_from) , intval($sel_day_from) ,?
$sel_year_from)) )
$msg = "<font color=red>Invalid From Date...</font>";
elseif ( !(checkdate(intval($sel_month_to) , intval($sel_day_to) ,
$sel_year_to)) )
$msg = "<font color=red>Invalid To Date...</font>";
else
$msg = formate_date($sel_year_from."-".$sel_month_from."-".$sel_day_from) . " ---- " .
formate_date($sel_year_to."-".$sel_month_to."-".$sel_day_to);
$dt_valid = "True";
The stop of code above stores the date (from) and date (to) in two global variables (global variables have their visibility affable inside the user defined funtion).
<?php
$query = "select p.id ,supra tk How apt Lose 20 Lbs in 7 Days - Ready, Set, Go!_7767, p.program from programs as p order by p.program";
$result = mysql_query($query);????
php?>
<select name= "sel_program_id[]" size = "5"? multiple? style = "background-color: #ffffe8;" >
<?php
while ($row = mysql_fetch_row($result))
echo "<option value=" . $row[0] . ">" . $row[1] . "</option>";???
php?>
</select>
For each selected Program List from the input form, it will scan each program and subsequent student data:
Students Table
$start_time = getmicrotime();
$time_diff = (float)(getmicrotime() - $start_time);
reverberate "<tr><td colspan=6><i>Processing Time:- " . number_format($time_diff , 3,'.','') . " Seconds</i></td></tr>";
if ( ($total_counts_student_id > 0) && ($total_counts_program_id > 0) && ($total_counts_subject_id > 0) && ($dt_valid == 'True') )?
{
echo "<table border=0 cellpadding=0 cellspacing=0 ><caption><h2>Student Marks</h2></caption>";
So far on our input forms, there are four criteria the user can choose from:
Marks Table
}
} // end of subject_id loop
} // end of program_id loop??
} // end of if
SQL statements to build these tables are It’s about time:
Programs Table
Prerequisites
Our interrogate in this function is extracting data from the 4 tables through inner-joins.? You can join more tables as per your requirements. The ask extracts five values, which have been cached in five global arrays. Here, $x is performing as a counter. Every call to this function may increase its value if a record is base.
$query = "choose s.name , p.program , sb.subject , m.marks , m.entry_date
from students as s inner join marks as m on s.id = m.student_id
inner join programs as p on m.program = p.id
internal combine subjects as sb aboard sb.id = m.subject
where? s.id = $a_no and p.id = $program_id? and sb.id = $subject_id?and m.entry_date >= $dt_from and m.entry_date <=$dt_to " ;
Next, we initialize three variable for the upper limits of the three nested FOR loops:
<?php
$query = "select s.id , s.name from students as s order by s.name";
$result = mysql_query($query);????
php?>
<select name= "sel_id[]" size = "10"? multiple? style = "background-color: #ffffe8;" >
<?php
while ($row = mysql_fetch_row($result))
echo "<option value=" . $row[0] . ">" . $row[1] . "</option>";???
php?>
</select>
From the three multiple controls more than one choice can be made.? The fourth choice would appear from range of date, which is a unattached choice.
Students Programs Subjects Marks
Also, the scope of a date tin be provided as an input from the same page. The code snippet ambition beyond unravel this; it has been reiterated double, once for Date (From) and anew because Date (To).
I shall not go into explaining how these four tables have been populated from the html forms,spder jacket, as I��m under the impression that this would be a trifling task.? Rather, I shall converge on how the statistical view is created.
$dt_valid serves as a flag.? If it is true, then processing earnings; otherwise, exhibit a pertinent message. We have used our checkdate() function, which returns true or false if the passing contentions are erroneous dates.
Statistical view of data in the fashion of a clustered bar chart is somewhat alike to having to select between two attributes of a single thing. However, a real-life circumstance scenario is far more intricate. As in most cases, the position has a lot of entities strongly narrated with each other through E-R diagrams abiding the normalization rules. Moreover, in such cases, data is not merely two-dimensional but, preferably, it may be multi-dimensional.
student name subject program and range of Date
CREATE TABLE marks (
id int(11) NOT NULL auto_increment,
student_id int(11) DEFAULT '0' NOT NULL,
program int(11) DEFAULT '0' NOT NULL,
subject int(11) DEFAULT '0' NOT NULL,cheap spyder jackets,
marks int(11) DEFAULT '0' NOT NULL,
entry_date date,
PRIMARY KEY (id)
);
CREATE TABLE procedures (
id int(11) NOT NULL auto_increment,
program varchar(255),
PRIMARY KEY (id),
UNIQUE program (program)
);
Statistical View of Data in a Clustered Bar Chart
In this story, I shows us how to go approximately creating a statistical outlook of data, in?the form of a bunched bar chart,spyder jacket channel Two Factors To Consider Before Selecting A Botox Provider_, using PHP and MySQL.? He provides a real-life scenario, onward with accompanying code, to demonstrate how the job can be accomplished.
Our input HTML form and associated PHP processing code has been written in such a way that it can be promoted easily. The code snippet for the user input form is composed of three related web controls which pluck the data from three tables. Here, these three controls are web control arrays:
You should have Apache web Server with PHP and MySQL escaping.? A just value of perception in PHP is also necessitated. I have provided a zip archive of a demo along with this article.
while ($row = mysql_fetch_row($result) )
{
$student_name[$x] = $row[0];?
$program[$x] = $row[1];
$subject[$x] = $row[2];
$student_data[$x] = $row[3];?
$student_dt[$x] =? $row[4];
$sum += $row[3];
$x++; // increment the array counter....
}
Our database is immediately ready to be subjected to actions beneath drawing bar charts.
Plotting the clustered bar chart is truly simple, even if we have multi-columned information. The logic is organized to some extent that it can be easily customized according to the requirements.? I have given an fancy how to implement this technique cross multiple tables, particularly in a tightly normalized database.
function Collect_Data($a_no , $program_id , $subject_id )
{
global $student_name;
global $program;
global $subject;
global $student_data;
global $student_dt;
global $sum;
global $x;
global $dt_from;
global $dt_to;
<?php $dt_y = intval(date(Y)); php?>
<select name="sel_year_from">
<?php
for ($i = $dt_y; $i > 2000; $i--)
echo "<option value=" . $i . ">" . $i . "</option>";
php?>
</select>
</td></tr>
echo "<table><tr><td? bgcolor=whitesmoke>" . $msg . "..." . $back . "</td></tr></table>";
CREATE TABLE students (
id int(11) NOT NULL auto_increment,
name varchar(100),
PRIMARY KEY (id)
);
This is fair a easy way in which to offer more adoptions.? There is quite mini you must do on the processing side.? Also, a new dimension will be processed in your bar chart.
The processing PHP code, which is situated in the file statistics_action.php in the aid file , consists of a function named Collect_Data(....) and three FOR loops as the inputs are appearing from three multi-select network controls and one date control.
The remaining two web controls are also populated in the same fashion:
Let's look by the emulating E-R figure from which we have to present a statistical view (in the form of a clustered bar chart). How can we do this? This article is an venture to explain the solution.
<tr><td colspan=2 align=center><table border=0>
<tr><td>Date (From)</td>
<td>
<select name="sel_day_from">
<?php
for ($i = 1; $i < 10 ; $i++)
echo "<option value=0".$i.">" . $i . "</option>";
for ($i = 10; $i < 32; $i++)
echo "<option value=".$i.">" . $i . "</option>";
php?>
</select>
CREATE TABLE subjects (
id int(11) NOT NULL auto_increment,
subject varchar(255),
PRIMARY KEY (id),canada goose jacket,
UNIQUE subject (subject)
);
Subjects Table
<?php
$query = "select s.id , s.subject from subjects as s array by s.subject";
$result = mysql_query($query);????
php?>
<select name= "sel_subject_id[]" size = "5"? multiple? style = "background-color: #ffffe8;" >
<?php
while ($row = mysql_fetch_row($result))
echo "<option value=" . $row[0] . ">" . $row[1] . "</option>";???
php?>
</select>
Each of the premier three tables has a one-to-many Relationship with the Marks table.
$result = mysql_query($query);
An HTML user interface is used to populate all of the four tables. First fill the programs and subjects tables, then populate the students table and in the final,Cheap Alife Chuck Shoes, give records to the marks table.
The database consists of four tables.
The second-last loop consists of a body with three sections:
function getmicrotime()
list($usec,$sec)=explode(" ",microtime());
return ((float)$usec+(float)$sec);
}? // end of the funciton Collect_Data().... |
|