0
    function GetFieldFromStelling($Field, $ID, $mysqli) {
        $query = $mysqli->prepare("SELECT ? FROM stemmen WHERE ID = ?");
        $query->bind_param("si", $Field, $ID);
        $query->execute();
        $query->bind_result($results);
        $query->fetch();            
        return $results;
    }

Hi everyone,

I am trying to add a variable to the select statement but it does not work, does anyone have any input?

The output of the function is the string I put in the $Field part.

Thanks!

MaxM
  • 1
  • 1
  • 2
    You cannot use parameters for column (and table) names – aynber Nov 07 '22 at 19:33
  • Not an exact match, but the mechanics and reasoning are the same: https://stackoverflow.com/questions/182287/can-php-pdo-statements-accept-the-table-or-column-name-as-parameter – aynber Nov 07 '22 at 19:34

0 Answers0