problem-inserting data in tables with one to one relation

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
minos_mks
Forum Commoner
Posts: 69
Joined: Thu Feb 04, 2010 1:58 am

problem-inserting data in tables with one to one relation

Post 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

}
minos_mks
Forum Commoner
Posts: 69
Joined: Thu Feb 04, 2010 1:58 am

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

Post by minos_mks »

thank you very much
Post Reply