Tommy_Sauce
Tommy_Sauce

Reputation: 11

Writing data to multiple tables using SQL

I would like to use 1 data entry form on my website to collect data and send this to two tables in HeidiSQL but can not work out how to do it!

I have tried the following:

Try 1 -

$sql = "INSERT INTO bookings(CustomerEmail,DJName,DatePerformance,VenueName,Town) 
    VALUES('$CustomerEmail','$DJName','$DatePerformance','$VenueName','$Town')";
        
$sql = "INSERT INTO venue(VenueName) VALUES('$VenueName')" ;

This did not work as the second $sql code 'canceled' out the first

Try 2 -

$sql = "INSERT INTO bookings(CustomerEmail,DJName,DatePerformance,VenueName,Town) VALUES('$CustomerEmail','$DJName','$DatePerformance','$VenueName','$Town')"."INSERT INTO venue(VenueName) VALUES('$VenueName')" ;

I tried using the . to concatenate both but this didn't work at all.

Im new to web development so have hit a wall.

Thanks

Upvotes: 1

Views: 83

Answers (0)

Related Questions