I got my PHP/MYSQL start about a year ago with K. Yank book “Build Database Driven Website”, so I am [U]still[U]new
My current project is building a real estate website – almost done. The CMS has form pages that ADD / EDIT / DELETE residential records. The ADD page creates a new residential record in the database; and the EDIT and DELETE pages manage each residential record.
Each residential record has four pictures associated with that record. Adding pictures is done in the EDIT page. Under my design, the admin must first create a record using the ADD page.
——–ISSUE———
The ADD page inserts a record into the RESIDENTIAL TABLE; RES_ID is the primary key. I also need the ADD page to INSERT the newly created RES_ID into the IMAGES TABLE field IMAGE_RES_ID.
[code=php]
<?php
if ($submit): // add new CONTENT from form below
$sqlinsert = “INSERT INTO residential SET
res_order=’$resorder’,
res_head=’$reshead’,
res_description=’$resdescription’,
res_price=’$resprice'”;
if (@mysql_query($sqlinsert)) {
echo(“<p>New Residential property added!</p>”);
} else {
echo(“<p>Error adding new Residential property: ” . mysql_error() . “</p>”);
}
?>
My research and thoughts make this code (or something like it) look like a solution but my testing proves me wrong on its placement in the code and it syntax.
$id = mysql_insert_id();
$imginsert = “INSERT INTO image SET image_res_id=’$id'”;
Any one see where I went off the road? Thanks in advance.
Greg