Reputation: 87
I am trying to check the database if data for a specific date exists. If it does not exist, then a new row needs to be inserted into the database for that date. Here's my code so far in php/sql (after db login info), but I can't get it to work:
// gets two data points from form submission
$tablename = $_GET['tablename'];
$date = $_GET['date'];
//Fetching from your database table.
$query = "IF NOT EXISTS (SELECT * FROM $tablename WHERE date = $date) BEGIN Insert into $tablename (date, var1, var2) VALUES ('$date', '', ''); END"
$result = mysql_query($query);
Please HELP...
Upvotes: 1
Views: 403