I'm creating a plugin that will have a variable amount of user input. I need a way to be able to loop through that variable amount in an SQL statement. Basically what I want is this
$sqlArray = [
'loop_carousel' => 'on',
'stop_on_hover' => 'on',
'reverse_order' => '',
'navigation_arrows' => 'on',
'show_pagination' => 'on'
];
$sql = "UPDATE $table_name
SET
".
foreach ($sqlArray as $key => $value) {
echo "$key = '$value'";
}.
";";
Which would output a statement like
UPDATE wp_carousel
SET
loop_carousel = 'on',
stop_on_hover = 'on',
reverse_order = '',
navigation_arrows = 'on',
show_pagination = 'on';
But obviously, it fails. So what are my options?