I have a logic hook that will fire on before_retrieve to update a field depending on what is entered in to other field of a related module i have the code working all except how to retrieve the id of the record currently open
PHP Code:<?php
$id="THIS IS WHERE I NEED THE RECORD ID";
mysql_connect("localhost", "username", "password");
mysql_select_db("database");
$query = "SELECT adf21_testecd6testing_ida from adf21_testif21_testing2_c where adf21_test3552esting2_idb='$id' and deleted=0";
$results = mysql_query($query);
while($row=mysql_fetch_array($results)){
$id2=$row['adf21_testecd6testing_ida'];
$query2="SELECT num1_c, num2_c from adf21_testing_cstm where id_c='$id2'";
$results2 = mysql_query($query2);
while($row2=mysql_fetch_array($results2)){
$num1=$row2['num1_c'];
$num2=$row2['num2_c'];
$num3=$num3+$num2+$num1;
}
}
$update_query="UPDATE adf21_testing2_cstm SET num3_c='$num3' WHERE id='$id'"
?>


LinkBack URL
About LinkBacks



Reply With Quote
Bookmarks