im building a property website.
the current situation is that I have a property.php that includes many isset _get
to determine the output. The property page is querying the property table and depending on the field allowing different types of input. I am allowing uploads of multiple images which is in the images table. This is all working perfectly.
the problem is that due to the two tables, I need to insert two queries (I've defined tables and columns and fields into variables so I can reuse them in different pages and sites :) )
$qry=mysql_query("INSERT INTO $table($col1,$col2,$col3,$col4,$col5,$col6,$col7,$col8,$col9,$col10,$col11,$col12,$col13,$col14)VALUES('$field','$field2','$field3','$field4','$field5','$field6','$field7','$field8','$field9','$field10','$field11','$field12','$field13','$field14')", $con);
if(!$qry)
{
die("Query Failed: ". mysql_error());
}
else
{
include 'upload.php';
the upload.php does all the movement of the images and runs another query
$query="INSERT into images (`property`,`image`) VALUES(SELECT LAST_INSERT_ID(),'$file_name'); ";
my problem is that the property field is never populated with the last_insert_id()
and always 0.
basically I want to be able to track all the images uploaded to the id of the property table where it was inserted during the submit and I believe last_insert_id()
would work to my needs - but not working with the current code.
before anyone talks about mysqli and pdo, let me mention that I will do it at a later stage.