CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> Archive -> GotoCode Archive

 Insert same record in two columns of database

Print topic Send  topic

Author Message
Rui Nunes
Posted: 01/09/2003, 5:35 AM

When i insert or update the record "Phone" the value "X" of the "Phone" go to the table "Clients", column "Phone_a" and "Phone_b" to MSAccess database.

EX: I insert the phone 999999999 and this number go to the table "Clients",
Columns "Phone_a" and "Phone_b"

Can anyone could help me please and give me the "after update" and "after insert" code for Code Charge? Not for Code Charge Studio.

I past 1 week seach how to make this.
Thank you!
Nicole
Posted: 01/10/2003, 6:38 AM

Rui,
Here are sample ASP and PHP code for the AfterInsert and After Update events of CC form:
PHP
$db->query("insert into Clients (Phone_a, Phone_b) values (".$fldX.", ".$fldX.")");
ASP
cn.execute "insert into Clients (Phone_a, Phone_b) values ("& fldX& ", "& fldX &")"

Assuming that record is inserted into Clients table. If you have problems with updating Clients table (if you need update) please let me know the key field the tables are joint on.
Rui Nunes
Posted: 01/10/2003, 10:51 AM

Dear Nicole,

Thank you for your help but, i insert the code you give me
cn.execute "insert into Clients (Phone_a, Phone_b) values ("& fldX& ", "& fldX &")" in "After update" and "After insert".

And give me always same error "INSERT INTO sintax error"

I go to the database verify, and the number in column "Phone_a" is ok but in the column "Phone_b" is always empty :-(

I try modify the code but i dont understand anything of SQL and give me always many errors...

Have you a suggestion?

Thank you for your time.
feha
Posted: 01/10/2003, 12:18 PM

This is same as Nicole's answer just other variant so it might work You ...

example
$phonenumber="0055-333333";

$db->query = ("INSERT INTO Clients (Phone_a, Phone_b) VALUES('$phonenumber', '$phonenumber');");

For UPDATE there is other query ...

Regards
feha
[www.vision.to]
Rui Nunes
Posted: 01/10/2003, 3:22 PM

Dear feha

Thank you, but dont work.

When one person insert on the form one number, this number go to the
Table "Clients" columns "Phone_a" and "Phone_b"

The value inserted in the form, ex: xxx-xxxxx go to the columns
"Phone_a" and "Phone_b".

The clients only have to insert one time the phone number and this
phone number go to the columns "Phone_a" and "Phone_b".

Insert record "Phone" ---> goto database ---> Table Clients
---> Columns "Phone_a" = "Phone_b"


Thank you
feha
Posted: 01/10/2003, 11:50 PM

I don't understand what do You mean?!

$phonenumber="0055-333333";//ENTERED ONCE

$db->query = ("INSERT INTO Clients (Phone_a, Phone_b) VALUES('$phonenumber', '$phonenumber');");

AFTER THAT YOU WILL GET THE 0055-333333 VALUE IN BOTH Phone_a, Phone_b.

JUST TAKE $fldphone or whatever is Your form field for phone number ...
(This is an example for PHP/MySQL)

IF YOU INTEND TO USE THIS IN AFTER INSERT EVENT THEN YOU HAVE TO USE UPDATE NOT INSERT ...
IF YOU USE UPDATE THEN YOU MUST USE WHERE ... SO THE UPDATE WILL UPDATE EXACT RECORD ....

Hope this helps
Regards
feha
[www.vision.to]






feha
Posted: 01/11/2003, 12:03 AM

Here is sample AFTER INSERT

$client_id= mysql_insert_id();//retrives last inserted id

$db->query("UPDATE Clients SET Phone_b='$phonenumber' WHERE client_id='$client_id'");

In case You have already inserted a phone number in first INSERT RECORD than You need only to update column Phone_b.

To be more exact You can update both columns:

$db->query("UPDATE Clients SET Phone_a='$phonenumber',Phone_b='$phonenumber' WHERE client_id='$client_id'");

Regards:
feha
[www.vision.to]

Rui Nunes
Posted: 01/11/2003, 10:52 AM

Dear feha

Can you send me the code in ASP please.
I can find a converter PHP2ASP, only ASP2PHP :-(

Can you help me please?

Thank you
feha
Posted: 01/11/2003, 6:44 PM

Sorry I don't program in ASP


   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.