I need to make a row name be dynamic based on my choice. How can I make the following code work for me using bind_param?
UPDATE: main problem that my dynamic row name doesn't work. It gives me an error -
PHP Fatal error: Call to a member function execute() on a non-object
Code
$myitem = 'something2';
$result = getResult($myitem);
function getResult($myitem) {
global $DBconnection;
$rowName = $myitem;
$stmt = $mysqli->prepare("SELECT
id,
something1,
something2,
something3
FROM table
WHERE ? = ? // ERROR
");
$stmt->bind_param("ss", $rowName, $myitem); // ERROR
$stmt->execute();
$stmt->bind_result($id, $something1, $something2, $something3);
while ($stmt->fetch()){
$row[] = array('id' => $id, 'something1' => $something1, 'something2' => $something2, 'something3' => $something3);
}
$stmt->close();
if (isset($row)) {
return ($row);
}
}
Thank you.