This is my PHP PDO code:
<?php
$number = 1;
function result($conn) {
$sql = 'SELECT name FROM customerdata';
foreach ($conn->query($sql) as $row) {
print " ". $number ." ". $row['name'] . " <br> "; // this is line 6
}
}
result($conn);
?>
This is the error, I am getting:
Notice: Undefined variable: number in C:\xampp\htdocs\website\a.php on line 6