Many Thanks!!
I have my code working now!
Unique field: ncheque
If emply will be NULL value
PHP:
if($_POST["titular"]!="" &&
$_POST["valorcheque"]!="" &&
$_POST["banco"]!="" &&
$_POST["datavencimento"]!=""){
$tipo_pagamento =
$_POST["tipo_pagamento"];
$ncheque = $_POST["ncheque"];
$ncheque = ($ncheque != "") ?
"'" . $ncheque . "'" :
"NULL";
$titular = $_POST["titular"];
$valorcheque =
virgulatoponto($_POST["valorcheque"]);
$banco = $_POST["banco"];
$vencimento =
datatobanco($_POST["datavencimento"]);
$cidadeorigem =
$_POST["cidadeorigem"];
$notas = $_POST["notas"];
$recibo = $_POST["recibo"];
$compra = $_POST["compra"];
$data = date("Y-m-d");
$db = new Database();
$db->query("Insert into pagamentos
(tipo_pagamento,titular,ncheque,vencimento,valor,datacadastr
o,banco,cidadeo--
rigem,notas,recibo,compra)
values ('$tipo_pagamento','$titular',
$ncheque,'$vencimento','$valorcheque','$data','$banco','$cid
adeorigem','$no--
tas','$recibo','$compra')");
}
SQL:
CREATE TABLE `pagamentos` (
`ID` int(6) NOT NULL auto_increment,
`tipo_pagamento` varchar(12) default NULL,
`titular` varchar(80) default NULL,
`ncheque` varchar(10) default NULL,
`valor` float(10,2) default NULL,
`vencimento` date default NULL,
`datacadastro` date default NULL,
`banco` tinyint(6) default NULL,
`cidadeorigem` varchar(60) default NULL,
`notas` longtext,
`recibo` varchar(20) default NULL,
`compra` longtext,
PRIMARY KEY (`ID`),
UNIQUE KEY `ncheque` (`ncheque`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
Best Regards,
PiRiCa
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "PHP-Masters" group.
To post to this group, send email to PHP-Masters googlegroups.com
To unsubscribe from this group, send email to
PHP-Masters-unsubscribe googlegroups.com
For more options, visit this group at http://gro
ups.google.com/group/PHP-Masters
-~----------~----~----~----~------~----~------~--~---
|