Avatar of ftpphptest1
ftpphptest1

asked on 

get the sum from mysql

i want to store the sum of (gaptime > 1 min ) to the $rdowntime['totalGaptime'];
but the php is not worked
why ?

condition is gaptime > 1 , but seem it is not worked
my table for column gaptime is in format of 00:00:00.687
hours:min:sec.mini sec
is that the type of gaptime needed to set in DATETIME?

 as now i have error
i think the condition can not fufill
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\OEE.php on line 194

<?php 
$con = mysql_connect(localhost, root, 1234567);
if (!$con){
 die('Could not connect: ' . mysql_error());
}
mysql_select_db(final)or die('&quot;cannot select DB&quot;');
 
$resultdowntime = mysql_query("SELECT SUM(gaptime) AS totalGaptime FROM machine1 HAVING gaptime > 1"); 
 
$rdowntime=mysql_fetch_array($resultdowntime);
 
echo $rdowntime['totalGaptime'];
?>
 
 
CREATE TABLE machine1 (
 ID INT NOT NULL auto_increment,
 Date varchar(20),
 Time varchar(20) NOT NULL default '',
 GapTime TIME NOT NULL,
 MachineNumber varchar(20) NOT NULL default '',
 PRIMARY KEY (ID)
)type=myisam auto_increment=1;

Open in new window

PHP

Avatar of undefined
Last Comment
Roger Baklund

8/22/2022 - Mon