I am trying to store the id from the database into an array using PHP but it shows an error.
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "webmirchi";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT id FROM jobinfo";
$result = $conn->query($sql);
$data = array();
while($row = $result->fetch_row())
{
$data[] = $row['id'];
}
$arrlength = count($data);
for($x = 0; $x < $arrlength; $x++) {
echo $data[$x];
echo "<br>";
}
$conn->close();
?>
Notice: Undefined index: id in E:\xampp\htdocs\demo1.php on line 19