Am pulling out my hairs trying to figure this out…
<?php
include('connection.php');
$template = $_GET['templateID'];
$campaign = $_GET['campaignID'];
// Grab everything in the campaign manager
$cm = mysql_query("SELECT * FROM campaign_manager WHERE campaign ='$campaign'") or die(mysql_error());
while($temp = mysql_fetch_array($cm)){
//Checks if Template is already attached
if($temp['paragraph'] == $template){
echo 'Template is already attached - <a href="http://general:8888/templates">Back</a>';
} else {
if($temp['paragraph'] == '0' || $temp['paragraph'] == null ){
mysql_query("UPDATE campaign_manager SET paragraph = '$template' WHERE campaign = '$campaign'") or die(mysql_error());
}
else {
$geo = $temp['geo'];
$list = $temp['list'];
mysql_query("INSERT INTO campaign_manager(campaign,paragraph,geo,list) VALUES('$campaign','$template','$geo','$list')");
}
}
}
?>
My first IF is checking for a DUP. If it isn’t it, it then checks if the field is either 0 or NULL. If THAT CHECK outs THEN it should add a new record into the ‘campaign manager’. Although currently its displaying the echo of the first IF & its adding the duplicate record into the campaign manager. Why & HOW is this happening?
Wow, so after rethinking my code over the weekend. I came up with this…
It works finally.