my code is this
$sql = "SELECT * FROM faculty";
foreach ($pdo->query($sql) as $row) {
foreach ($row as $key => $value) {
echo $key."-".$value."<br/>";
}
}
it’s fairly simple what i’m doing. My question is why am i getting the same value
two times, one with a key the name of the row in mysql (e.g “surname”) and one the position of the array.
Thank you for your time.
That’s because your default fetch mode is set to
Try e.g.
instead.
see also: http://docs.php.net/pdo.constants