On the front end of my PHP, I want the user to decided what field to insert into among multiple fields. I can do that with multiple 'if' statements like I have below, but that makes for a long code. Can I use a variable for the field, i.e Song_id, Album_id? I've tried doing something like "Insert into Song(?) values (?)" but that doesn't seem to work.
case "insert":
if ($table=="Song"){
if($field=="Song_id"){
$stmt = $db->prepare("INSERT into Song(Song_id) values (?)");
$stmt->bindValue(1, $_POST['value'], PDO::PARAM_INT);
$stmt->execute();
echo "done";}
break;}
if ($table=="Song"){
if($field=="Alubm_id"){
$stmt = $db->prepare("INSERT into Song(Album_id) values (?)");
$stmt->bindValue(1, $_POST['value'], PDO::PARAM_INT);
$stmt->execute();
echo "done";}
break;}
etc, etc, etc.
Thanks!