I'm having an issue with using a value for a select in a different update statement.
Below, I run a select statement and the print_r($existingContent)
is printing the object with num_rows, field_count etc. But I can't figure out how to dump the ID I need.
I'm currently getting an error at this line:
WHERE id = $existingContent->existingContent
saying that $existingContent is an undefined property. I'm assuming it's becuase of how I'm setting it from the select but I can't debug because my print_r isn't showing how my actual response is structured. I just need the ID from that select statement to be used in my where clause
$checkContentExists = "SELECT cont_id as existingContent FROM panels WHERE panel_type_id = $panelID AND page_id = $pageID";
$existingContent = $mysqlConn->query($checkContentExists);
print_r($existingContent);
$updateContent = "
UPDATE content
SET content = '$content'
WHERE id = $existingContent->existingContent;";
if($mysqlConn->query($updateContent) === TRUE){
echo "Record Updated";
}
UPDATE
while ($row = mysqli_fetch_assoc($existingContent)){
print_r($row);
//If i use the commented out code I get a 500 error
// $updateContent = "
// UPDATE content
// SET content = '$content'
// WHERE id = $row[existingContent];
// ";
// $updateResult = $mysqlConn->query($updateContent);
}