Page 1 of 1

problem-inserting data in tables with one to one relation

Posted: Tue May 11, 2010 10:45 am
by minos_mks
i need to get the last Automated value on (ads_deitals_items) table to and insert the same value on (ad_d_jobs) table case they have one to one relationship
but the problem that the vale of the max(item_code) in the select it doesn't retrieve the maximam value but retrieve ( Resource id #9 ). Can anybody help me in that , thank you



function add_jobs_tables ($address,$zipcode,$disc,$job_type,$Price,$note)
{

global $connection;

$query_ads_deitals_items = "insert into ads_deitals_items(cat_code,address,zipcode)
values (1,\"$address\",\"$zipcode\")";

$query_ads_deitals_items = mysql_query($query_ads_deitals_items,$connection);
confirm_query($query_ads_deitals_items);

$get_last_item_code = "select max(item_code)
from ads_deitals_items " ;
echo $get_last_item_code ;
echo "<br />";
$item_code = mysql_query($get_last_item_code,$connection );
echo $item_code ;

echo "<br />";
confirm_query($get_last_item_code);

$query_add_d_jobs = "insert into ad_d_jobs(price,job_type,ad_disc,note,item_code)
values (\"$Price\",\"$job_type\",\"$disc\",\"$note\",$get_last_item_code)";
$query_add_d_jobs = mysql_query($query_add_d_jobs,$connection);
confirm_query($query_add_d_jobs);

$states = 1 ; // data has been added sucsssfully
return ($states); // send the $authorized states

}

Re: problem-inserting data in tables with one to one relatio

Posted: Tue May 11, 2010 11:19 am
by mikosiko

Re: problem-inserting data in tables with one to one relatio

Posted: Wed May 12, 2010 8:32 am
by minos_mks
thank you very much