This topic is locked
[SOLVED]

 Update a field from another table

7/8/2010 2:56:22 AM
PHPRunner General questions
romaldus author

I want productname field updated based on ProductID
Where in PRODUCTS Table

take a look at the screenshot :


[size="4"]How i use After record added event of Order_details table to make ProductName updated with data from PRODUCTS table when saved?[/size]
i tried to use :

$sql = "UPDATE order_details SET ProductName='".$values["ProductName"]."' WHERE ProductId=" . $values["ProductId"];

CustomQuery($sql);


but not works <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=14767&image=2&table=forumtopics' class='bbc_emoticon' alt=':(' /> <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=14767&image=3&table=forumtopics' class='bbc_emoticon' alt=':(' />

A
ann 7/8/2010

Hi,
to fill ProductName field based on the value of ProductID set up ProductName field as dependent dropdown (Lookup Wizard tab on the Edit as settings dialog on the Visual Editortab).

Check the tutorial ('How to setup dependent dropdown boxes on Edit/Add pages'):

http://xlinesoft.com/phprunner/php-database.htm

Choose Edit box with AJAX popupoption if needed.

romaldus author 7/8/2010



Hi,
to fill ProductName field based on the value of ProductID set up ProductName field as dependent dropdown (Lookup Wizard tab on the Edit as settings dialog on the Visual Editortab).

Check the tutorial ('How to setup dependent dropdown boxes on Edit/Add pages'):

http://xlinesoft.com/phprunner/php-database.htm

Choose Edit box with AJAX popupoption if needed.


Thanks Ann. We have been using dependent dropdown features in PHPRUNNER since the previous releases of the software.

BTW i have some reason to avoid using it in particular situation, for example when working with a large database, lookup more than 20000 record (ProductID) using dependent dropdown with low bandwidth connection sometimes pain. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=51073&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />
As you see from the screenshot, i made the ProductName field as a READ ONLY field (i want the ProductName updated automatically each time a record inserted to database).
cheers

L
lucas 7/8/2010



Thanks Ann. We have been using dependent dropdown features in PHPRUNNER since the previous releases of the software.

BTW i have some reason to avoid using it in particular situation, for example when working with a large database, lookup more than 20000 record (ProductID) using dependent dropdown with low bandwidth connection sometimes pain. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=51081&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />
As you see from the screenshot, i made the ProductName field as a READ ONLY field (i want the ProductName updated automatically each time a record inserted to database).
cheers


I have the same doubt! I enter the id and get various information which is in another table for the current table.

must enter data in another table! but do not want to retype!

A
ann 7/9/2010

Hi,
you can fill in these value using 'Insert a record into another table' predefined action (Add action button on the Events tab) in the After record added event on the Events tab. Although it will be progressed after you click the save button.

romaldus author 7/13/2010



Hi,
you can fill in these value using 'Insert a record into another table' predefined action (Add action button on the Events tab) in the After record added event on the Events tab. Although it will be progressed after you click the save button.


[size="4"]I found the solution. Just use a very simple SQL query[/size] <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=51129&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />
on AFTER RECORD ADDED an AFTER RECORD UPDATED events just add:

$sql = "UPDATE order_details SET ProductName =(SELECT ProductName FROM products WHERE ProductID=ProductID)";

CustomQuery($sql);