You have to fetch your statement into an associative array (or something else) then use it.
You have errors in your SQL and your php too please check below
- in your SQL you shouldn't surround column names by
' at the place use backticks `
bindParam as it name says, it is used to bind 1 parameter at a time, so in your code you have to use 2 bindParam lines, one for each parameter, or create an array with the variables you want to pass to your prepared statement and pass this array to execute as I did in my code.
if ($stmt = $con->prepare("SELECT PName, Player_price, Player_points, Total_points FROM Keepers_points WHERE `WeekNo`=? AND `PlayerNO`=?"))
{
$data=array($Week_ID, $GK_2);
$stmt->execute($data);
$stmt->setFetchMode(PDO::FETCH_ASSOC);
while($array=$stmt->fetch()){
print_r($array);
}
}
Or you can use fetchAll() to have all the results into an array
if ($stmt = $con->prepare("SELECT PName, Player_price, Player_points, Total_points FROM Keepers_points WHERE `WeekNo`=? AND `PlayerNO`=?"))
{
$data=array($Week_ID, $GK_2);
$stmt->execute($data);
$array=$stmt->fetchAll();
print_r($array);
}
Check the manual for more options: http://www.php.net/manual/en/
SIDE NOTE: it is better to use AND not && as that's the standard SQL