I know that I can't use a WHERE clause in an insert statement, but I need to exclude certain entries from being inserted to my table. Here is what I'm working with:
foreach($json['Meetings'] as $meet) {
$add1 = $meet['AddressLine1'];
$add2 = $meet['AddressLine2'];
$cpid = $meet['CongressPersonID'];
$cpsd = $meet['CongressPersonStateDistrict'];
$start = $meet['Start'];
$end = $meet['End'];
$loc = $meet['Location'];
$meetwith = $meet['MeetingWith'];
$name = $meet['Name'];
$ph = $meet['PhoneNumber'];
$meetid = $meet['Id'];
$status = $meet['Status'];
$sql = "INSERT INTO Meetings (AddressLine1, AddressLine2, CongressPersonID, CongressPersonStateDistrict, End, Location, MeetingWith, Meeting_Id, Name, PhoneNumber, Start, Status)
VALUES ('$add1', '$add2', '$cpid', '$cpsd', '$end', '$loc', '$meetwith', '$meetid', '$name', '$ph', '$start', '$status')";
I have a JSON file which I'm parsing through PHP and it's inserting just fine into my database.
The only bit of info I'm concerned with is Status. The value for that can be "Confirmed" or "NotRequested."
I only want to insert the row if Status = "Confirmed."
Really, I would like to exclude those entries that are not confirmed as early in the process as possible. I am just not very experienced in this yet.
One workaround I thought of was to insert everything, then immediately go in and remove any entry where Status != "Confirmed" but that seems like an innefficient way to do it.