I'm having problems the following code gives me no results. however if I uncomment out the indicated line, and comment out the bind_param line it works, but isn't that defeating the purpose of mysqli? my var_dump gives my string(1) "1"
function teams($mysqli, $league_id) {
echo 'league id = ' . var_dump($league_id);
$sql = "SELECT team_id, team_name FROM teams where league_id='?'";
// $sql = "SELECT team_id, team_name FROM teams where league_id='".$league_id."'";
$stmt = $mysqli->prepare($sql);
$stmt->bind_param('i', $league_id);
$stmt->execute();
$stmt->bind_result($col1, $col2);
while($stmt->fetch()) {
$results[] = array(
'team_id' => $col1,
'team_name' => $col2
);
}
$stmt->close();
var_dump($results);
return $results;
}