$qryp2="INSERT INTO `cleopark`.`t_reservation` (
`id` ,
`today` ,
`entrance` ,
`adult` ,
`kids` ,
`infant` ,
`tot` ,
`g_tot` ,
`pers_id`
)VALUES (
NULL,
CURDATE(),
'$date',
'$adult',
'$children',
'$infant',
'$total',
'$grand_tot', here i want to get the id of the second table to use it
)";
$qryp1="INSERT INTO `cleopark`.`personal` (
`id` ,
`name` ,
`address` ,
`telephone` ,
`emal` ,
`city` ,
`country` ,
`t_res_id`
)VALUES (
NULL, '$family',
'$address',
'$tele',
'$emalb',
'$cityb',
'$country', here i want to get the id of the first table to use it
)";
all i need is to get the id of the first table and display it in the second table in slect * query
and also
i need to display the second id in the first table
Why do you need to cross-reference like that? One of those two foreign keys should be enough.
Like this, it's a bit like the story about the chicken and the egg
I don't see the point of having two tables if you are doing a 1 for 1 linking between rows in the tables. If this is the design then why don't you just make it one table. You are going to have redundant data regardless.
A better way to do it would be to take the personal information, check to see if it is already in the database (from a previous transaction) and use that ID in your reservation table.
If a reservation can have more than one 'personal' data row then you would need an intersection table between the two tables to handle the many-to-many relationship.
Bookmarks