CodeCharge Studio
search Register Login  

Visual Web Reporting

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

YesSoftware Forums -> CodeCharge Studio -> PHP

 Update another table after insert record

Print topic Send  topic

Author Message
adorni

Posts: 120
Posted: 02/01/2012, 7:15 AM

I insert this record:

COLUMN1 COLUMN2
2012101 Manuel

After insert this record i need to UPDATE table TESTING, search the number 2012101 in the table and update.

How i can do this???

THanks for example! (i{m not expert in php)
View profile  Send private message
ckroon

Posts: 869
Posted: 02/01/2012, 11:44 AM

Quote adorni:
I insert this record:

COLUMN1 COLUMN2
2012101 Manuel

After insert this record i need to UPDATE table TESTING, search the number 2012101 in the table and update.

How i can do this???

Thanks for example! (i{m not expert in php)

Ok! Here you go.. untested....put this in the AFter Insert Event.
Change the connection name to yours and also the primarykeyfield name.


////////////////////////////////////////////
global $DBConnection1
$db = new clsDBConnection1;
$db1 = new clsDBConnection1;
$db2 = new clsDBConnection1;
////////////////////////////////////////////
$sql= "SELECT MAX(primarykeyfield) as last FROM Table1";
$db->query($sql);
while($db->next_record())
{
$last = $db->f("last");

$sql=" SELECT * FROM Table1 WHERE primarykeyfield = '$last' ";
$db1->query($sql);
while($db1->next_record())
{
$name = $db1->f("column2");
$number = $db1->f("column1");

$sql=" UPDATE testing SET column2 = '$name' WHERE column1 ='$number' ";
$db2->query($sql);
}
}
}
_________________
Walter Kempees...you are dearly missed.
View profile  Send private message
adorni

Posts: 120
Posted: 02/01/2012, 12:01 PM

Thanks! I donīt undestand where i specify the "table2" for UPDATE record. in the script that you send me i only found "table1"

Sorry but i have poor php experience

Thanks again!
View profile  Send private message
adorni

Posts: 120
Posted: 02/02/2012, 3:55 AM

I sorry... "testing" is the table 2. Thanks. Where in the script i read "COLUMN1" from x primary key?

Very very thanks
View profile  Send private message

Add new topic Subscribe to topic   


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

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


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