The first part of the code, where the id is fetched from another sheet works fine and the data from while($row = mysqli_fetch_assoc($result))
are returned correctly. What I'm trying to do though is put this data in each input value by doing this <input name="visitingdate" type="date" value="<?=$row['visitingdate']?>">
. I'm getting this error: "Notice: Trying to access array offset on value of type null in "Directory" on line "line"." This is what I've got so far:
<?php
require('config.php');
$id=$_REQUEST['id'];
$query = "SELECT * from records where id='".$id."'";
$result = mysqli_query($link, $query) or die ( mysqli_error());
while($row = mysqli_fetch_assoc($result))
{
echo "<tr>";
echo "<td>" . $row["visitingdate"]. "</td>";
echo "<td>" . $row["department"] . "</td>";
echo "<td>" . $row["visitingreason"]. "</td>";
echo "<td>" . $row["importance"]. "</td>";
echo "<td>" . $row["visitorname"]. "</td>";
echo "<td>" . $row["company"]. "</td>";
echo "<td>" . $row["internalrecipientname"]. "</td>";
echo "<td>" . $row["visitinglocation"]. "</td>";
echo "<td>" . $row["ETA"]. "</td>";
echo "<td>" . $row["ETD"]. "</td>";
echo "<td>" . $row["HRverification"]. "</td>";
echo "<td>" . $row["visitcompleted"]. "</td>";
}
?>
<!DOCTYPE html>
<html>
<body>
<form action="records.php" method="post">
<br><br><br>
Visiting Date<br><input name="visitingdate" type="date" value="<?=$row['visitingdate']?>"><br><br>
Department <br><input name="department" type="text" value="<?=$row['department']?>"><br><br>
Visiting Reason<br><input name="visitingreason" type="text" value="<?=$row['visitingreason']?>"><br><br>
Importance<br><input name="importance" type="text" value="<?=$row['importance']?>"> <br><br>
Visitor Name<br><input name="visitorname" type="text" value="<?=$row['visitorname']?>"><br><br>
Company<br><input name="company" type="text" value="<?=$row['company']?>"><br><br>
Internal Recipient Name<br><input name="internalrecipientname" type="text" value="<?=$row['internalrecipientname']?>"><br><br>
Visiting Location<br><input name="visitinglocation" type="text" value="<?=$row['visitinglocation']?>"><br><br>
ETA<br><input name="ETA" type="time" value="<?=$row['ETA']?>"><br><br>
ETD<br><input name="ETD" type="time" value="<?=$row['ETD']?>"><br><br>
HR Verification<br><input name="HRverification" type="checkbox" value="<?=$row['HRverification']?>"><br><br>
Visit Completed<br><input name="visitcompleted" type="checkbox" value="<?=$row['visitcompleted']?>"><br><br>
<input name="submit1" type="submit" value="Update">
</form>
<?php
?>
</body>
</html>