Code: Select all
//insert SQL Statement
$sql = "INSERT INTO CB_rateplan $rows VALUES " . implode ( ', ', $hold ).";";
$num_rows_rp = mysql_num_rows($results_rp);
if(isset($results_rp) && isset($num_rows_rp)){
$rs= mysql_fetch_assoc($results_rp);
echo $rs['productid']."=".$temp[21]."<BR>"; // seeing what i grabs
if( $temp[21] != $rs['productid']){
$add_rp = "INSERT INTO CB_rateplan $rows VALUES $values WHERE productid !='".$temp[21]."';";
echo $add_rp;
}else{
for($i=0; $i< count($column); $i++){
$update_rp = "UPDATE CB_rateplan SET ".$column[$i]."='".$temp[$i]."' WHERE productid='". $temp[21]."';";
echo $update_rp;
}//for loop
} //if 2
echo "Worked";
}else{
//SQL insert stuff that already works with no problems
//echo $sql;
//for calling strings for update and insert statements
//print_r($temp);
//mysql_query($sql);
//Stick it in thur biotch!
/*if(mysql_query($sql)){
print "<BR>info inserted successfully";
}else{
print "<BR>did not insert";
}*/
}// If end
echo "<BR> VALUE".$temp[21];now what i need to do is for every match run an update and for anything that doesn't match i need to insert it as a new row. And it has to filter through all records in XML and the table
example
table:row
productid = 12345, 56789, 11111, 22222
XML: 21
21 = 12345, 56789. 11111, 22222, 33333
so first 4 records woould udate and last record in XML would insert.
i can't quite figure out what to do here... how to set the loops and embedded loops. Anyone got any clues?