[SOLVED] Loop does not work....

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
paolone
Forum Commoner
Posts: 37
Joined: Tue Jun 11, 2002 10:18 am

[SOLVED] Loop does not work....

Post by paolone »

Hi dears... I have this code to check for a missing line from results from database, and i have a problem on the looping... infact it does not rendere all the rows, but only the first one...

Where do i miss something?

Thanks to all those who will help... :)

Code: Select all

if(mysql_num_rows($result)) 
    { 
    //open table, if data exists. 
    echo "<table width=".$total." border='0'><tr><td width=".$width_transaction_name." bgcolor=".$bgcolor_head."><div align=".$alignment_head."><font color=".$font_color_head."><strong>TRANS. NAME</strong></font></div></td><td width=".$width_transaction_response_time." bgcolor=".$bgcolor_head."><div align=".$alignment_head."><font color=".$font_color_head."><strong>TRANS. RESPONSE TIME</strong></font></div></td><td width=".$width_execution_time." bgcolor=".$bgcolor_head."><div align=".$alignment_head."><font color=".$font_color_head."><strong>EXEC. TIME</strong></font></div></td></tr>"; 
     
//start the rendering of the results 
$myrow = mysql_fetch_array($result); 

//alternate color on results 
$bgcolor = ($bgcolor=='#E5E5E5'? '#F3F3F3' : '#E5E5E5'); 

//define Variable for time handling 
$timeHandling = str_replace(',','',$myrow['scenario_elapsed_time']);             

//define hour 
$hour = (int)($timeHandling / 3600 + ;             

//define minutes 
$v_mins = (int)($timeHandling / 900); 
$mins = (($v_mins*15) % 60); 

//Set variable to set up time increment 
$timeMark = 0; 

//render the result 
while ($mins != $timeMark) 
{ 
            //Log all intervening times for which there is no event 
            echo "<tr><td width=".$width_transaction_name." bgcolor=".$bgcolor."><font color='red'><div align=center><strong>++++</font></div></strong></td><td width=".$width_transaction_response_time." bgcolor=".$bgcolor."><font color='red'><div align=center><strong>++++</font></div></strong></td><td width=".$width_execution_time." bgcolor=".$bgcolor."><font color='red'><div align=center><strong>SCRIPT ERROR</font></div></strong></td></tr>"; 
            if (($timeMark += 15) > 45) $timeMark = 0; 
            } 
            //Log the next event 
            echo "<tr><td width=".$width_transaction_name." bgcolor=".$bgcolor.">".$myrow['transaction_name']."</td><td width=".$width_transaction_response_time." bgcolor=".$bgcolor.">".$myrow['transaction_response_time']."</td><td width=".$width_execution_time." bgcolor=".$bgcolor."><strong><font color=red>".$hour." : ".$mins."</strong></font></td></tr>"; 
            if (($timeMark += 15) > 45) $timeMark = 0; 
            }     
             
    //at the end of the renderinig close the table         
    echo "</table>";
(this is only the last part of the code...)
Last edited by paolone on Tue Apr 26, 2005 7:10 am, edited 1 time in total.
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

You need to get each row, and use it as the loop... At present you only get one return value, hence only first row...

Code: Select all

while ($myrow = mysql_fetch_array($result)) {
// Process Row...
}
paolone
Forum Commoner
Posts: 37
Joined: Tue Jun 11, 2002 10:18 am

Post by paolone »

:D Thanks...

But still, i don't get the reesult expected from this script...

Infact i have a database from wich i retrive data to convert to time (H:M)

It is the log file for a script running every 15 minutes. It can be that the script fail, and so when dysplaing the datas i get a gap or 30 or more minutes in case of ultiple fafils.


Let's say the result from the database is
(after the conversion of the 'scenario_elapsed_time' value)

script abc 8:00
script aff 8:15
script tbf 8:45
script AZE 9:15
script SSc 9:45

And what i need to do when displaing the result is to render a dummy row for each missing 15 minutes gap.
Like this:
script abc 8:00
script aff 8:15
!! SCRIPT ERROR !!
script tbf 8:45
!! SCRIPT ERROR !!
script AZE 9:15
!! SCRIPT ERROR !!
!! SCRIPT ERROR !!
script SSc 9:45
But as of now (with the script above), what i get is :

script aff 8:00
!! SCRIPT ERROR !!
!! SCRIPT ERROR !!
!! SCRIPT ERROR !!
!! SCRIPT ERROR !!
script SER 8:00
!! SCRIPT ERROR !!
!! SCRIPT ERROR !!
!! SCRIPT ERROR !!
!! SCRIPT ERROR !!
script DEE 8:00
!! SCRIPT ERROR !!
!! SCRIPT ERROR !!
!! SCRIPT ERROR !!
!! SCRIPT ERROR !!
script ffc 8:00
!! SCRIPT ERROR !!
!! SCRIPT ERROR !!
!! SCRIPT ERROR !!
!! SCRIPT ERROR !!
...
I really don't see what i can do... :?

Sorry if the problem is bigger than the begin , i can rename the topic if you prefer...

Thanks a lot...
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

Can you provide the database table structure and the sqlquery.
paolone
Forum Commoner
Posts: 37
Joined: Tue Jun 11, 2002 10:18 am

Post by paolone »

The table structure is the following...
# Table structure for table `kpi`
#
# Creation: Mar 09, 2005 at 04:42 PM
# Last update: Mar 09, 2005 at 05:43 PM
#

CREATE TABLE `kpi` (
`Line_Number` int(11) NOT NULL default '0',
`transaction_name` varchar(100) NOT NULL default '',
`transaction_response_time` varchar(128) NOT NULL default '',
`scenario_elapsed_time` varchar(128) NOT NULL default '0',
`transaction_father_tree_path` varchar(10) NOT NULL default '',
`script_name` varchar(100) NOT NULL default '',
`transaction_end_status` varchar(100) NOT NULL default '',
`group_name` varchar(100) NOT NULL default '',
`VuserID` varchar(20) NOT NULL default ''
) TYPE=MyISAM;
And the query is in the full script...

Code: Select all

<?php 
//Connect to DB
mysql_connect("localhost", "root", "");
mysql_select_db("support");

//get the value of the ddmenu
$transactionName = $_REQUEST['transactionName'];

######################################
##    set variable for layout       ##
######################################
$font_color_head = '003066';
$alignment_head = 'center';
$bgcolor_head = '#A6ADC7';
$width_transaction_name = '320';
$width_transaction_response_time = '250';
$width_execution_time = '150';
$total = ($width_transaction_name + $width_transaction_response_time + $width_execution_time);

//build query
$search_string = "SELECT transaction_name, transaction_response_time, scenario_elapsed_time FROM `kpi`";

//filter request by transaction name
if ($transactionName != "All") {$search_string .= "WHERE `transaction_name` LIKE '".$transactionName."'";}

// Render query string.
$query = $search_string; 

// take the results and then execute the search.
$result = mysql_query($query);

//retrieve number of records found
$numrows = mysql_num_rows($result);

//set array to check against
//$timeCheck = array('0','15','30','45');

if(mysql_num_rows($result)) 
	{ 
	//open table, if data exists.
	echo "<table width=".$total." border='0'><tr><td width=".$width_transaction_name." bgcolor=".$bgcolor_head."><div align=".$alignment_head."><font color=".$font_color_head."><strong>TRANS. NAME</strong></font></div></td><td width=".$width_transaction_response_time." bgcolor=".$bgcolor_head."><div align=".$alignment_head."><font color=".$font_color_head."><strong>TRANS. RESPONSE TIME</strong></font></div></td><td width=".$width_execution_time." bgcolor=".$bgcolor_head."><div align=".$alignment_head."><font color=".$font_color_head."><strong>EXEC. TIME</strong></font></div></td></tr>";
	
//start the rendering of the results
$myrow = mysql_fetch_array($result); 
 
//alternate color on results
$bgcolor = ($bgcolor=='#E5E5E5'? '#F3F3F3' : '#E5E5E5');

//define Variable for time handling
$timeHandling = str_replace(',','',$myrow['scenario_elapsed_time']);			

//define hour
$hour = (int)($timeHandling / 3600 + ;			

//define minutes
$v_mins = (int)($timeHandling / 900);
$mins = (($v_mins*15) % 60); 

//Set variable to set up time increment
$timeMark = 0;

while (mysql_fetch_array($result)){
//render the result
	while ($mins != $timeMark) 
			{
				//Log all intervening times for which there is no event
				echo "<tr><td width=".$width_transaction_name." bgcolor=".$bgcolor."><font color='red'><div align=center><strong>++++</font></div></strong></td><td width=".$width_transaction_response_time." bgcolor=".$bgcolor."><font color='red'><div align=center><strong>++++</font></div></strong></td><td width=".$width_execution_time." bgcolor=".$bgcolor."><font color='red'><div align=center><strong>SCRIPT ERROR</font></div></strong></td></tr>";
				if (($timeMark += 15) > 45) $timeMark = 0;
				} 
				//Log the next event
				echo "<tr><td width=".$width_transaction_name." bgcolor=".$bgcolor.">".$myrow['transaction_name']."</td><td width=".$width_transaction_response_time." bgcolor=".$bgcolor.">".$myrow['transaction_response_time']."</td><td width=".$width_execution_time." bgcolor=".$bgcolor."><strong><font color=red>".$hour." : ".$mins."</strong></font></td></tr>";
				if (($timeMark += 15) > 45) $timeMark = 0;
			}
				
	}		
//at the end of the renderinig close the table		
echo "</table>";
	
	
?>
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

I havent got time to read all that bit if you add

Code: Select all

$result = mysql_query($query) or die(mysql_error()); //On line 30
we may disover the problem quicker ;-)
paolone
Forum Commoner
Posts: 37
Joined: Tue Jun 11, 2002 10:18 am

Post by paolone »

You are right... 'cause i always forgot to add this "error displayinig" function, but here the problem is not in the query, that work, but in finding the way to manipulate the result to achieve what i describe above... :)
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

Your structure as I can see it is not correct... (Unfortunately I cannot quickly see what you are trying to do so a pointer...)

Code: Select all

while ($row=mysql_fetch_array($result)){
    //render the result
    if ($row['transaction_response_time']>$testvalue) {
      //Log all time
    } elseif ($row['transaction_response_time']>$testvalue+15) {
      // do somthing else
      $testvalue=$row['transaction_response_time'];
    } else {
      // Yet another thing
    }
}
or something similar...
paolone
Forum Commoner
Posts: 37
Joined: Tue Jun 11, 2002 10:18 am

Post by paolone »

ok... mabe this help...

this is a source file as a text, not a a mysql resources, but it helps to understand...
Event, AAA, OK ,8:00
Event, BBB, OK ,8:30
Event, CCC, OK ,8:45
Event, DDD, OK ,9:15
Event, EEE, OK ,9:45
Event, FFF, OK ,10:00
Event, GGG, OK ,11:00
Event, HHH, OK ,12:00
Event, III, OK ,12:30
Event, LLL, OK ,12:45
Event, MMM, OK ,13:00
Event, NNN, OK ,13:15
Event, OOO, OK ,13:45
Event, PPP, OK ,14:15
Event, PPP, OK ,14:45
Event, QQQ, OK ,15:30
Event, RRR, OK ,16:00
Event, RRR, OK ,16:15
Event, RRR, OK ,16:30
Event, RRR, OK ,16:45
Event, SSS, OK ,17:00
Event, SSS, OK ,17:30
Event, RRR, OK ,17:45
Event, TTT, OK ,18:00
And with this code

Code: Select all

<?php

$font_color_head = '003066';
$alignment_head = 'center';
$bgcolor_head = '#A6ADC7';
$width_transaction_name = '320';
$width_transaction_response_time = '250';
$width_execution_time = '150';
$total = ($width_transaction_name + $width_transaction_response_time + $width_execution_time);
$bgcolor = ($bgcolor=='#E5E5E5'? '#F3F3F3' : '#E5E5E5');

// Get the data tokenized by line (event) 
$lines = file ("events.txt"); 
// Tokenize the time into hours/minutes 
$lines = str_replace (':', ',', $lines); 
// Bust the tokens into an array 
foreach ($lines as $theLine) 
{ 
    $theLine = rtrim ($theLine); 
    $event [] = explode (",", $theLine); 
} 
// set a variable that will contain the increment (counter)
$timeMark = 0; 
	echo "<table width=".$total." border='0'><tr><td width=".$width_transaction_name." bgcolor=".$bgcolor_head."><div align=".$alignment_head."><font color=".$font_color_head."><strong>TRANS. NAME</strong></font></div></td><td width=".$width_transaction_response_time." bgcolor=".$bgcolor_head."><div align=".$alignment_head."><font color=".$font_color_head."><strong>TRANS. RESPONSE TIME</strong></font></div></td><td width=".$width_execution_time." bgcolor=".$bgcolor_head."><div align=".$alignment_head."><font color=".$font_color_head."><strong>EXEC. TIME</strong></font></div></td></tr>"; 

$bgcolor = ($bgcolor=='#E5E5E5'? '#F3F3F3' : '#E5E5E5');

// Trundle through the events 
foreach ($event as $theEvent) 
{ 
   
	// Log all intervening times for which there is no event 
    while ($theEvent [4] != $timeMark) 
    { 	
		
		echo "<tr><td width=".$width_transaction_name." bgcolor='red'><font color='white'><div align=center><strong>++++</font></div></strong></td><td width=".$width_transaction_response_time." bgcolor='red'><font color='white'><div align=center><strong>++++</font></div></strong></td><td width=".$width_execution_time." bgcolor='red'><font color='white'><div align=center><strong>SCRIPT ERROR</font></div></strong></td></tr>";        
		if (($timeMark += 15) > 45) $timeMark = 0; 
    } 
    // Log the next event 
	echo "<tr><td width=".$width_transaction_name." bgcolor=".$bgcolor.">".$theEvent [1]."</td><td width=".$width_transaction_response_time." bgcolor=".$bgcolor.">".$theEvent [2]."</td><td width=".$width_execution_time." bgcolor=".$bgcolor."><strong>".$theEvent [3]." : ".$theEvent [4]."</strong></td></tr>";
    if (($timeMark += 15) > 45) $timeMark = 0; 
} 
echo "</table>";

?>
I get the right result as i expect from the other one (the previous one posted)...

the problem is that in this one there is the "foreach ($event as $theEvent)" statement at the begin on the loop that i cannot "translate" in a similar one when the data is coming from the database.....

Is it clear now? [/quote]
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

If each row returned contained just Event, TTT, OK and 18:00 (four fields similar to previous only slight changes required to code...

Code: Select all

while ($row=mysql_fetch_row($result) 
{ 
    $event &#1111;] = $row;
} 
// set a variable that will contain the increment (counter)
$timeMark = 0; 
    echo &quote;&lt;table width=&quote;.$total.&quote; border='0'&gt;&lt;tr&gt;&lt;td width=&quote;.$width_transaction_name.&quote; bgcolor=&quote;.$bgcolor_head.&quote;&gt;&lt;div align=&quote;.$alignment_head.&quote;&gt;&lt;font color=&quote;.$font_color_head.&quote;&gt;&lt;strong&gt;TRANS. NAME&lt;/strong&gt;&lt;/font&gt;&lt;/div&gt;&lt;/td&gt;&lt;td width=&quote;.$width_transaction_response_time.&quote; bgcolor=&quote;.$bgcolor_head.&quote;&gt;&lt;div align=&quote;.$alignment_head.&quote;&gt;&lt;font color=&quote;.$font_color_head.&quote;&gt;&lt;strong&gt;TRANS. RESPONSE TIME&lt;/strong&gt;&lt;/font&gt;&lt;/div&gt;&lt;/td&gt;&lt;td width=&quote;.$width_execution_time.&quote; bgcolor=&quote;.$bgcolor_head.&quote;&gt;&lt;div align=&quote;.$alignment_head.&quote;&gt;&lt;font color=&quote;.$font_color_head.&quote;&gt;&lt;strong&gt;EXEC. TIME&lt;/strong&gt;&lt;/font&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&quote;; 
 
$bgcolor = ($bgcolor=='#E5E5E5'? '#F3F3F3' : '#E5E5E5');
 
// Trundle through the events 
foreach ($event as $theEvent) 
{ 
   
    // Log all intervening times for which there is no event 
    while ($theEvent &#1111;4] != $timeMark) 
    {     
        
        echo &quote;&lt;tr&gt;&lt;td width=&quote;.$width_transaction_name.&quote; bgcolor='red'&gt;&lt;font color='white'&gt;&lt;div align=center&gt;&lt;strong&gt;++++&lt;/font&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/td&gt;&lt;td width=&quote;.$width_transaction_response_time.&quote; bgcolor='red'&gt;&lt;font color='white'&gt;&lt;div align=center&gt;&lt;strong&gt;++++&lt;/font&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/td&gt;&lt;td width=&quote;.$width_execution_time.&quote; bgcolor='red'&gt;&lt;font color='white'&gt;&lt;div align=center&gt;&lt;strong&gt;SCRIPT ERROR&lt;/font&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;&quote;;        
        if (($timeMark += 15) &gt; 45) $timeMark = 0; 
    } 
    // Log the next event 
    echo &quote;&lt;tr&gt;&lt;td width=&quote;.$width_transaction_name.&quote; bgcolor=&quote;.$bgcolor.&quote;&gt;&quote;.$theEvent &#1111;1].&quote;&lt;/td&gt;&lt;td width=&quote;.$width_transaction_response_time.&quote; bgcolor=&quote;.$bgcolor.&quote;&gt;&quote;.$theEvent &#1111;2].&quote;&lt;/td&gt;&lt;td width=&quote;.$width_execution_time.&quote; bgcolor=&quote;.$bgcolor.&quote;&gt;&lt;strong&gt;&quote;.$theEvent &#1111;3].&quote; : &quote;.$theEvent &#1111;4].&quote;&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;&quote;;
    if (($timeMark += 15) &gt; 45) $timeMark = 0; 
} 
echo &quote;&lt;/table&gt;&quote;;
Is a direct conversion, even if not very tidy. (Sorry Haven't got time to make a tidy version and check it at present)... Note uses mysql_fetch_row not mysql_fetch_array.
paolone
Forum Commoner
Posts: 37
Joined: Tue Jun 11, 2002 10:18 am

Post by paolone »

sorry m8... i'm really stuck on this... can u please be more clear?

If i use the code as it is like this :

Code: Select all

if(mysql_num_rows($result)) 
	{ 
	//open table, if data exists.
	echo "<table width=".$total." border='0'><tr><td width=".$width_transaction_name." bgcolor=".$bgcolor_head."><div align=".$alignment_head."><font color=".$font_color_head."><strong>TRANS. NAME</strong></font></div></td><td width=".$width_transaction_response_time." bgcolor=".$bgcolor_head."><div align=".$alignment_head."><font color=".$font_color_head."><strong>TRANS. RESPONSE TIME</strong></font></div></td><td width=".$width_execution_time." bgcolor=".$bgcolor_head."><div align=".$alignment_head."><font color=".$font_color_head."><strong>EXEC. TIME</strong></font></div></td></tr>";
	
	//start the rendering of the results
	$myrow = mysql_fetch_array($result); 
	 
	
	//Set variable to set up time increment
	$timeMark = 0;
	
	while ($myrow = mysql_fetch_array($result)){
	
	//alternate color on results
	$bgcolor = ($bgcolor=='#E5E5E5'? '#F3F3F3' : '#E5E5E5');
	
	//define Variable for time handling
	$timeHandling = str_replace(',','',$myrow['scenario_elapsed_time']);			
	
	//define hour
	$hour = (int)($timeHandling / 3600 + ;			
	
	//define minutes
	$v_mins = (int)($timeHandling / 900);
	$mins = (($v_mins*15) % 60); 
	//render the result
	//while ($mins != $timeMark) 
			//{
				//Log all intervening times for which there is no event
				//echo "<tr><td width=".$width_transaction_name." bgcolor=".$bgcolor."><font color='red'><div align=center><strong>++++</font></div></strong></td><td width=".$width_transaction_response_time." bgcolor=".$bgcolor."><font color='red'><div align=center><strong>++++</font></div></strong></td><td width=".$width_execution_time." bgcolor=".$bgcolor."><font color='red'><div align=center><strong>SCRIPT ERROR</font></div></strong></td></tr>";
				//if (($timeMark += 15) > 45) $timeMark = 0;
				//} 
				//Log the next event
				print "<tr><td width=".$width_transaction_name." bgcolor=".$bgcolor.">".$myrow['transaction_name']."</td><td width=".$width_transaction_response_time." bgcolor=".$bgcolor.">".$myrow['transaction_response_time']."</td><td width=".$width_execution_time." bgcolor=".$bgcolor."><strong><font color=red>".$hour." : ".$mins."</strong></font></td></tr>";
				//if (($timeMark += 15) > 45) $timeMark = 0;
			}
				
	}		
//at the end of the renderinig close the table		
echo "</table>";
i get the result table with alternate colors and with all the value coming from the database. the commented lines are the one that should allow me to insert the "dummy" row where there is a gap of 15 or more minutes... But it doesn't...
:roll: :roll: :roll: :?
paolone
Forum Commoner
Posts: 37
Joined: Tue Jun 11, 2002 10:18 am

Post by paolone »

If in the meantime someone has a solution on this it would be great... :? :? :?
paolone
Forum Commoner
Posts: 37
Joined: Tue Jun 11, 2002 10:18 am

Post by paolone »

Hello... finally i've managed to get the solution and i can now display the result as expected... the dummy row is shown, but i need a couple of advices now... :?

this is the part of the code that does the job :

Code: Select all

if ($filetosql != '')
{
	foreach($lines as $theLine)
		{
			$theLine = rtrim($theLine);
			$event [] = explode("\t", $theLine);
		}	
		print "<table width=".$total." border='0'><tr><td width=".$width_transaction_name." bgcolor=".$bgcolor_head."><div align=".$alignment_head."><font color=".$font_color_head."><strong>TRANS. NAME</strong></font></div></td>";
		print "<td width=".$width_transaction_response_time." bgcolor=".$bgcolor_head."><div align=".$alignment_head."><font color=".$font_color_head."><strong>TRANS. RESPONSE TIME</strong></font></div></td>";
		print "<td width=".$width_execution_time." bgcolor=".$bgcolor_head."><div align=".$alignment_head."><font color=".$font_color_head."><strong>EXEC. TIME</strong></font></div></td>";
		print "<td width=".$width_date." bgcolor=".$bgcolor_head."><div align=".$alignment_head."><font color=".$font_color_head."><strong>DATE</strong></font></div></td></tr>";
	
		//set timemark
		$timeMark = 0; 
		// Trundle through the events 
		foreach ($event as $theEvent) 
		{ //define Variable for time handling
			$timeHandling = str_replace(',','',$theEvent[2]);			
			//define hour
			$hour = (int)($timeHandling / 3600 + ;			
			//define minutes
			$v_mins = (int)($timeHandling / 900);
			$mins = (($v_mins*15) % 60); 
			
			while ($mins != $timeMark)
			{
				print "<tr>";
				print "<td width=".$width_transaction_name." bgcolor='red'><font color='white'>".$theEvent[0]."</font></td>";
				print "<td width=".$width_transaction_response_time." bgcolor='red'><font color='white'>####</font></td>";
				//print "<td width=".$width_transaction_response_time." bgcolor=".$bgcolor.">".$theEvent[6]."</td>";
				print "<td width=".$width_execution_time." bgcolor='red'><font color='white'>####</font></td>";
				print "<td width=".$width_date." bgcolor='red'><font color='white'>".$date."</font></td>";
				print "</tr>";
				if (($timeMark += 15) > 45) $timeMark = 0;
			}
			//alternate color on results
			$bgcolor = ($bgcolor=='#E5E5E5'? '#F3F3F3' : '#E5E5E5');			
			print "<tr>";
			print "<td width=".$width_transaction_name." bgcolor=".$bgcolor.">".$theEvent[0]."</td>";
			print "<td width=".$width_transaction_response_time." bgcolor=".$bgcolor.">".$theEvent[1]."</td>";
			//print "<td width=".$width_transaction_response_time." bgcolor=".$bgcolor.">".$theEvent[6]."</td>";
			print "<td width=".$width_execution_time." bgcolor=".$bgcolor.">".$hour." : ".$mins."</td>";
			print "<td width=".$width_date." bgcolor=".$bgcolor.">".$date."</td>";
			print "</tr>";
			if (($timeMark += 15) > 45) $timeMark = 0;
		}
	print "</table>";
	print "<br>";
	print "<input type='submit' name='submit' value='Insert in database'>";
}
a part of the result can be like this :
Transaction_OPSearch_nertnert_server52 4.438 12:45 2005-03-07
Transaction_OPSearch_nertnert_server52 5.11 13:0 2005-03-07
Transaction_OPSearch_nertnert_server52 #### #### 2005-03-07
Transaction_OPSearch_nertnert_server52 #### #### 2005-03-07
Transaction_OPSearch_nertnert_server52 4.188 15:45 2005-03-07
Transaction_OPSearch_nertnert_server52 #### #### 2005-03-07
Transaction_OPSearch_nertnert_server52 3.751 16:15 2005-03-07
My first point is...

Now that i have the result on the browser, with the error calculated, what is the best way to insert this data in MySQL?
My problem is that the error is generated by the calculation in the script, and i want it to be insertet as well...

The second (but not so important at the moment) is that if you see above i have a script that runs at 13:00 and the next one at 15:45. I should have 10 rows of errors but i have only 2, because it calculate the multiple of 15 and does not take in count that the script at 14:00, 14:15, 14:30, etc... didn't run successully.....
Post Reply