C
|
copper21 10/3/2015 |
You can update the other table on an "After record added" event. Go to the events page and go to the physician_profile table and go to the "Add" Page. From there, go to "After record Added" and use something like this: |
S
|
stec5345 author 10/6/2015 |
Thanks Brian. I seem to get a syntax error however when running this stating that to check for correct syntax near the where statement: You can update the other table on an "After record added" event. Go to the events page and go to the physician_profile table and go to the "Add" Page. From there, go to "After record Added" and use something like this: $sql = "UPDATE licenses SET LicClientID = ".$values['ClientID']." WHERE LicPhysID = ".$values['PhysID'].""; CustomQuery($sql); IF I am understanding you correctly, this should work. |
S
|
stec5345 author 10/6/2015 |
I think the logic needs to make this happen from an even on the licenses where when a license is added, it triggers the field within that table called LicClientID to be updated from the physician_profile table? Am I making sense? Thanks Brian. I seem to get a syntax error however when running this stating that to check for correct syntax near the where statement: Error type 256 Error description You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE LicPhysID =' at line 1 URL www.statmedcaredb.com/licenses_add.php?submit=1&fly=1& Error file C:\Inetpub\vhosts\statmedcaredb.com\httpsdocs\connections\MySQLiConnection.php Error line 142 SQL query UPDATE licenses SET LicClientID = WHERE LicPhysID = Any idea? |
C
|
copper21 10/7/2015 |
The error is occurring because LicPhysID doesn't have a value... |
A
|
Abul 10/23/2015 |
The error is occurring because LicPhysID doesn't have a value... SQL query UPDATE licenses SET LicClientID = WHERE LicPhysID = XXX? There is nothing after LicPhysID meaning ".$values['PhysID']." does not have a value. From the information that you provided, this is the example I was able to provide. Try it on the other table you were talking about on the ADD page. Let me know if that helps. You can always provide me with your table structures for both and i can try to go from there.
$sql = "UPDATE state SET country_id = ".$values['id']." FROM country WHERE countrynm = ".$values['country_name'].""; CustomQuery($sql);
Technical information Error type 256 Error description You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM country WHERE countrynm = USA' at line 1 URL localhost/test/state_add.php?ferror=1& Error file C:\xampp\htdocs\test\include\dbconnection.my.mysqli.php Error line 63 SQL query UPDATE state SET country_id = FROM country WHERE countrynm = USA |
C
|
copper21 10/24/2015 |
This statement doesn't look right... |
A
|
Abul 10/24/2015 |
This statement doesn't look right... Technical information Error type 256 Error description You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM country WHERE countrynm = USA' at line 1 URL localhost/test/state_add.php?ferror=1& Error file C:\xampp\htdocs\test\include\dbconnection.my.mysqli.php Error line 63 SQL query UPDATE state SET country_id = FROM country WHERE countrynm = USA It looks like ".$values['id']." doesn't have a value, therefore you are not seeing a value between country_id = & FROM. Also, the word FROM is not part of an UPDATE Statement as well. I would be better able to help you if you give me the two table structures. Give me the table names and the fields in the tables, also noting the primary keys fore each...if you have primary keys.
|
A
|
Abul 10/24/2015 |
I think I have accomplished this by writing BEFORE INSERT trigger at db table. This following trigger give me the result exactly what I am looking for. DROP TRIGGER CREATE DEFINER= root @localhost TRIGGER countryid_update BEFORE INSERT ON state FOR EACH ROW BEGIN SET @country_id=1; IF NEW.country_name IS NOT NULL THEN SELECT country.id INTO @country_id FROM country WHERE countrynm=NEW.country_name; SET NEW.country_id=@country_id; END IF; END;
|
![]() |
romaldus 11/3/2015 |
I have a table in which there is a field (int) I need to populate automatically based on a value from another table. eg. In my licenses table, I need the LicClientID field to auto populate with the ClientID from the physician_profile table where the inner joined licenses.LicPhysID = physician_profile.PhysID I don't have to have the LicClientID on the ADD page. I just want the value to populate the field in the DB automatically for future queries Any help available?
|
A
|
Abul 11/3/2015 |
On After Record Addedevent Try This :
|
![]() |
romaldus 11/3/2015 |
This code is good for Add/Edit pages but could you please let us know how can we use similar code for similar purpose in case we import new records from Excel File. There is no After Insert Record event on import_page.php. I appreciate your contributions.
|
A
|
Abul 11/4/2015 |
There is After Importevent in import page
|