I made a simple function that will go into the MYSQL DB and get the field I need based on an id. It works OUTSIDE the function. Inside the function the SQL statement is correct but I cannot figure out why it will not output the results of $row[$field]. Something I am doing wrong is not displaying when its inside the function.
function getVendor($field,$id) {
$sql = "SELECT $field from manufacturer where id=$id LIMIT 1";
echo $sql;
$result = $conn->query($sql);
while($row = $result->fetch_assoc()) {
echo $row[$field];
}
}
getVendor('name','2');