This topic is locked
[SOLVED]

 Mysql query for Addpage

3/6/2012 6:28:37 AM
PHPRunner General questions
S
sickacid author

Hi I've two table one with product (tabella_documenti_personali) and the last with expiration date (tabella_scadenze). I've connected wiht the follow mysql code:
SELECT

tabella_documenti_personali.id_documento,

tabella_documenti_personali.tipo_documento,

tabella_documenti_personali.patenti,

tabella_scadenze.data_scadenza

FROM tabella_documenti_personali

INNER JOIN tabella_scadenze ON tabella_documenti_personali.id_scadenzaRef = tabella_scadenze.Id_scadenza
if I put manually some data i can see the correct relation, a product with his expiration date.

But if i want to use add page i'cant insert new data because i get an error like this: Unknown column 'tabella_scadenze.data_scadenza' in 'field list' .
The question is.. for autoalimentate the tabella_scadenze when i put a new line in (tabella_documenti_pesonali) Have I to do this with afer record added in php, or there is another simple way?

C
cgphp 3/6/2012

In the "Before record added" event, update the tabella_scadenze table and unset the data_scadenza foreign field:

unset($values['data_scadenza']);
S
sickacid author 3/6/2012



In the "Before record added" event, update the tabella_scadenze table and unset the data_scadenza foreign field:

unset($values['data_scadenza']);



Hi, I've try and it works! but if I want to have access fields values i can't use $data["field"] ? I've do the follow code but with $write = $data["tipo_documento"] i get an error. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=64767&image=1&table=forumreplies' class='bbc_emoticon' alt=':unsure:' />
$scadenza = $values["data_scadenza"];

$IdDipendente = $values["id_dipendente_R"];

$write = $values["tipo_documento"];

$test = "UFFICIO";

$num = $values["numero"];

$note = "SCADENZA $write Numero $num";

unset($values['data_scadenza']);

global $conn;

$strSQLInsert1 = "insert into tabella_scadenze (Id_Dipendente, data_scadenza, scadenza_gestita, note, Destinatario_informazione) values ('".$IdDipendente."', '".$scadenza."', '0', '".$note."', '".$test."')";

db_exec($strSQLInsert1,$conn);

return true;

C
cgphp 3/6/2012

Read the docs about the "After record added" event: http://xlinesoft.com/phprunner/docs/after_record_added.htm

S
sickacid author 3/6/2012

I've solved with a small if statement to change id_number with text <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=64774&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' /> Thank you!