I'm new at PHP so please dont bust my chops.
I'm building a Knowledge base system, basic CRUD functionality. I'm getting stuck where i need to NULL all values for each column in a table.
This is basically the "Edit a KB" form. I have a checkbox array which on edit I want to clear the KB number from my category column on my table 'category_kb_members'.
My code works fine apart from this bit.
This is my current code:
//Clear all categories for this KB
while($catrow = mysqli_fetch_array($categorylist)){
$catname = "";
$catname = $catrow['name'];
mysqli_query ($dbc, "UPDATE category_kb_members SET $catname=NULL WHERE $catname ='$kbid';");
}
[Please note no need to comment abut SQL injection here as the source is clean from the database.]
"$Categorylist" is an array of Category names - the table I am updating has a column for each category.
"$kbid" is set from a $_GET from the URL and corresponds with the KB number to be removed and is valid and working.
My loop is to query and update each column to NULL the KB number if it exists in the column. The code later goes on to add these back in the the relevant columns.
I have run this query against MYSQL and it works fine SQL side.
Any ideas as to why the UPDATE is not working?