I'm not entirely sure how to do this and I've been stuck trying to figure this out. I want to be able to increment a single value inside an array every time a user presses a submit button which gets saved into a csv file. However, every time I try the number stays at 1.
Could I get some guidance? Here's what I have:
<?php $name = $_POST["Name"];
$grade = $_POST["Grade"];
$handle = fopen("users.csv", "a+t");
if (!$handle) {
die("error, can't open file!");
}
if (!flock($handle, LOCK_EX)) {
die("lock error!");
}
$count = 10;
for ($i = 0; $i < count($count); $i++) {
$count++;
fputcsv($handle, array($i++, $name, $grade)); }
fseek($handle, 0);
while (!feof($handle)) {
$record = fgetcsv($handle);
?>
<div>
ID Number: <?php echo $record[0]; ?><br/>
Name: <?php echo $record[1]; ?><br/>
Grade: <?php echo $record[2]; ?><br/>
</div> }
Thank you.