I have done a script, wich opens a file, i manipulate it, then i display this file with the results of the manipulation (the post titled "Loop does not work"...). now i need to send this result to the database, but i cannot figure out how to send te query to the MySql database.
first the script
Code: Select all
//get the filename and upload
$filetosql = $_REQUEST['filetosql'];
######################################
## 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';
$width_date = '150';
$total = ($width_transaction_name + $width_transaction_response_time + $width_execution_time + $width_date);
// Get the data tokenized by line (event)
$lines = file($filetosql);
$lines = str_replace('"', '', $lines);
//get the date from the file name
$filename = $filetosql;
preg_match('/_(\d{8})\.txt$/', $filename, $matches); //Extract the date
$dateRes = $matches[1]; //This is your date
//workaround the date format
$date = substr($matches[1], 4, 4) ."-". substr($matches[1], 2, 2) ."-". substr($matches[1], 0, 2);
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='Save data'>";
}Code: Select all
$theEventї0] in field ==> transaction_name
$theEventї1] in field ==> transaction_response_time
$hours $mins in field ==> Execution_time
$date in field ==> DateCode: Select all
$theEventї0] in field ==> transaction_name (insert the name of the transaction)
$theEventї1] in field ==> transaction_response_time (insert a '####')
$hours $mins in field ==> Execution_time (insert a '####')
$date in field ==> Date (insert the date)thanks guys...