RE: [PHP-DB] Adding times in php

2006-03-04 Thread Bastien Koert

I would consider adding either:

1. a virtual column in the sql to add up the times
2. issue another sql statement to get a total
3. store a total in a cookie / session initially

bastien



From: Allan [EMAIL PROTECTED]
Reply-To: Allan [EMAIL PROTECTED]
To: php-db@lists.php.net
Subject: [PHP-DB] Adding times in php
Date: Sat, 4 Mar 2006 15:13:13 +0800

Hi All

I have two tables with columns of times that it took to perform tasks eg:

  8:40
  6:50
  8:30
10:55
-
34:55 total time taken to complete the tasks in hours and minutes

I am able to add the times with sql however I need to add the totals to 
cone

up with a grand total and because of the makeup of the tables I cant use
sql. I am there for going to have to use php code and this is where the
problem comes in because in sql there is SEC_TO_TIME and TIME_TO_SEC
functions that allow easy addition of the times but I cant find an
equivalent in php. Does any one know of a way that I can add to times
together in php.

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] MySQL update statement problem

2006-03-04 Thread Kevin Davies - Bonhurst Consulting
Hi,

Apologies if this isn't the right place to ask - but I'm banging my head
against the wall with this one!

I'm trying to update a record in the table (creation script below) using the
following SQL statement:

UPDATE shop_customer SET eu_vat_number = SK1234567890 AND vat_amount = 0
AND total_amount = 8.4925 WHERE customer_id = 7 AND hash=dcd5e751

Before running the query the value for eu_vat_number is 'null', vat_amount
is 0.085 and total_amount = 8.5775.

After I run the query (mysql_affected_rows = 1) the values for vat_amount
and total_amount remain the same, but vat_number is changed to 0.

I've been looking at this most of the afternoon, and it's probably something
really simple but I just can't see it...

Any ideas?

Thanks in advance for your help...

Cheers,

Kev


-- Server version: 3.23.58
-- PHP Version: 4.3.10

CREATE TABLE `shop_customer` (
  `customer_id` int(11) NOT NULL auto_increment,
  `hash` varchar(8) NOT NULL default '',
  `first_name` varchar(255) NOT NULL default '',
  `last_name` varchar(255) NOT NULL default '',
  `email_address` varchar(255) NOT NULL default '',
  `member_id` int(11) default NULL,
  `address1` varchar(255) default NULL,
  `address2` varchar(255) default NULL,
  `town` varchar(255) default NULL,
  `county` varchar(255) default NULL,
  `postcode` varchar(255) default NULL,
  `country` int(11) NOT NULL default '0',
  `eu_vat_number` varchar(15) default NULL,
  `total_items` int(11) default '0',
  `net_amount` float default '0',
  `vat_amount` float default '0',
  `shipping_amount` float default '0',
  `total_amount` float default '0',
  `added` datetime NOT NULL default '-00-00 00:00:00',
  `payment_received` datetime default NULL,
  PRIMARY KEY  (`customer_id`)
) TYPE=MyISAM AUTO_INCREMENT=8 ;

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] MySQL update statement problem

2006-03-04 Thread Chris

You need to separate the SET arguments with commas, not ANDs...
It's really doing something like this:

UPDATE shop_customer SET eu_vat_number = (SK1234567890 AND vat_amount = 0
AND total_amount = 8.4925) WHERE customer_id = 7 AND hash=dcd5e751

(SK1234567890 AND vat_amount = 0 AND total_amount = 8.4925) evaluates to 
false (0) , so that's what gets set.


Kevin Davies - Bonhurst Consulting wrote:

Hi,

Apologies if this isn't the right place to ask - but I'm banging my head
against the wall with this one!

I'm trying to update a record in the table (creation script below) using the
following SQL statement:

UPDATE shop_customer SET eu_vat_number = SK1234567890 AND vat_amount = 0
AND total_amount = 8.4925 WHERE customer_id = 7 AND hash=dcd5e751

Before running the query the value for eu_vat_number is 'null', vat_amount
is 0.085 and total_amount = 8.5775.

After I run the query (mysql_affected_rows = 1) the values for vat_amount
and total_amount remain the same, but vat_number is changed to 0.

I've been looking at this most of the afternoon, and it's probably something
really simple but I just can't see it...

Any ideas?

Thanks in advance for your help...

Cheers,

Kev


-- Server version: 3.23.58
-- PHP Version: 4.3.10

CREATE TABLE `shop_customer` (
  `customer_id` int(11) NOT NULL auto_increment,
  `hash` varchar(8) NOT NULL default '',
  `first_name` varchar(255) NOT NULL default '',
  `last_name` varchar(255) NOT NULL default '',
  `email_address` varchar(255) NOT NULL default '',
  `member_id` int(11) default NULL,
  `address1` varchar(255) default NULL,
  `address2` varchar(255) default NULL,
  `town` varchar(255) default NULL,
  `county` varchar(255) default NULL,
  `postcode` varchar(255) default NULL,
  `country` int(11) NOT NULL default '0',
  `eu_vat_number` varchar(15) default NULL,
  `total_items` int(11) default '0',
  `net_amount` float default '0',
  `vat_amount` float default '0',
  `shipping_amount` float default '0',
  `total_amount` float default '0',
  `added` datetime NOT NULL default '-00-00 00:00:00',
  `payment_received` datetime default NULL,
  PRIMARY KEY  (`customer_id`)
) TYPE=MyISAM AUTO_INCREMENT=8 ;

  


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] MySQL update statement problem

2006-03-04 Thread Kevin Davies - Bonhurst Consulting
Jenaro,

You're absolutely right (',' instead of 'and' - schoolboy error!). I've
obviously been staring at the screen too long! Strange that MySQL accepted
it as a valid statement though.

Many thanks for the quick reply.

I'm off to have a lie down! :)

Thanks and regards,

Kevin


-Original Message-
From: Jenaro Centeno Gómez [mailto:[EMAIL PROTECTED] 
Sent: 04 March 2006 17:35
To: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] MySQL update statement problem

Maybe I am wrong, biut isn´this the rigth way to do this:

UPDATE shop_customer SET eu_vat_number = SK1234567890, vat_amount =
0,total_amount = 8.4925 
WHERE customer_id = 7 AND hash=dcd5e751


Sorry, I've not used too much MySQL but this is the rigth way in Oracle, 
PostgreSQL and SQLServer.

Hope this helps.

Kevin Davies - Bonhurst Consulting escribió:

Hi,

Apologies if this isn't the right place to ask - but I'm banging my head
against the wall with this one!

I'm trying to update a record in the table (creation script below) using
the
following SQL statement:

UPDATE shop_customer SET eu_vat_number = SK1234567890 AND vat_amount = 0
AND total_amount = 8.4925 WHERE customer_id = 7 AND hash=dcd5e751

Before running the query the value for eu_vat_number is 'null', vat_amount
is 0.085 and total_amount = 8.5775.

After I run the query (mysql_affected_rows = 1) the values for vat_amount
and total_amount remain the same, but vat_number is changed to 0.

I've been looking at this most of the afternoon, and it's probably
something
really simple but I just can't see it...

Any ideas?

Thanks in advance for your help...

Cheers,

Kev


-- Server version: 3.23.58
-- PHP Version: 4.3.10

CREATE TABLE `shop_customer` (
  `customer_id` int(11) NOT NULL auto_increment,
  `hash` varchar(8) NOT NULL default '',
  `first_name` varchar(255) NOT NULL default '',
  `last_name` varchar(255) NOT NULL default '',
  `email_address` varchar(255) NOT NULL default '',
  `member_id` int(11) default NULL,
  `address1` varchar(255) default NULL,
  `address2` varchar(255) default NULL,
  `town` varchar(255) default NULL,
  `county` varchar(255) default NULL,
  `postcode` varchar(255) default NULL,
  `country` int(11) NOT NULL default '0',
  `eu_vat_number` varchar(15) default NULL,
  `total_items` int(11) default '0',
  `net_amount` float default '0',
  `vat_amount` float default '0',
  `shipping_amount` float default '0',
  `total_amount` float default '0',
  `added` datetime NOT NULL default '-00-00 00:00:00',
  `payment_received` datetime default NULL,
  PRIMARY KEY  (`customer_id`)
) TYPE=MyISAM AUTO_INCREMENT=8 ;

  


-- 
 L.A. Jenaro Centeno Gómez
Administración de Redes y Bases de Datos
Alimentos La Concordia, S.A. de C.V.
Loma de Prados No. 1332
Col. La Marimba
Lagos de Moreno, Jal.
C.P. 47470
Tel.- 01 474 741 92 00 Ext. 9280


La informacion contenida en este mensaje y sus anexos es de caracter privado
y confidencial y para el uso exclusivo de la persona o institucion a la cual
ha sido enviado y para otros autorizados para recibirlo, por lo que no podra
distribuirse sin la autorizacion expresa del remitente.  Si usted no es el
destinatario a quien este mensaje fue dirigido o si no es un empleado
responsable del envio de este mensaje al destinatario, se hace de su
conocimiento que cualquier revision,  diseminacion, distribucion, copia u
otro uso o acto realizado con base en o relacionado con el contenido de este
mensaje y sus anexos está estrictamente prohibida y puede ser ilegal.
Asimismo, el presente mensaje no representa la manifestacion del
consentimiento de ninguna de las partes, por lo que no genera derecho u
obligación alguna para ambas sino hasta que sus representantes legales asi
lo manifiesten por escrito.  Si usted ha recibido este comunicado y sus
anexos por error, le solicitamos lo notifique inmediatamente al remitente
respondiendo a este correo y borre el presente y sus anexos de su sistema
sin conservar copia de los mismos. Se suprimieron acentos y caracteres
especiales para legibilidad del mismo. Gracias.  Alimentos La Concordia,
S.A. de C.V.

The information contained in this message and its attachments is private and
confidential and is intended solely for the use of the individual or entity
to whom it is addressed and others who are authorized to receive it;
therefore, its distribution cannot be possible without authorization from
the sender.   If you are not the intended recipient or an employee
responsible for delivering this message to the intended recipient, you are
hereby notified that any revision, dissemination, distribution, copying or
other use or action based upon or relative to the information contained in
this message and its attachments is strictly prohibited and may be unlawful.
You are also informed that the contents of this message shall not be
considered as an agreement between the parties and shall not bind any of
them until their attorneys decide to do so in writing.  If you have received
this message and its attachments by 

[PHP-DB] RE: Adding time in php

2006-03-04 Thread JeRRy
  Hi,
   
  All you need to do is run a query to your db to get the times.
   
  than use something like this:
   
  ?php 
  // Multiplying with varaibles 
$factorA = .01; 
$factorB = number_format(system_value('usercount'), 0); 
$product = $factorA * $factorB + .25; 
echo $product;
?
   
  What this one does is count a total number of user on the website, than use 
factorA and multiplies that with factorB + a certain value.
   
  But this won't bring it in-line to what you want, but you could run some code 
to work it out. (just divide by .60?)
   
  J
   
   
   
   
   
   


Hi AllI have two tables with columns of times that it took to perform tasks 
  eg:  8:406:508:30  10:55  -  34:55 total time taken to 
complete the tasks in hours and minutesI am able to add the times with sql 
however I need to add the totals to   cone  up with a grand total and because 
of the makeup of the tables I cant   use  sql. I am there for going to have to 
use php code and this is where the  problem comes in because in sql there is 
SEC_TO_TIME and TIME_TO_SEC  functions that allow easy addition of the times 
but I cant find an  equivalent in php. Does any one know of a way that I can 
add to times  together in php.