Я пытаюсь записать данные в CSV-файл, используя следующий код.
HTML
<html>
<body>
<form action="writeToExcel.php" method="post">
<center><h1>Personal Learning Goals Form</h1></center>
Student ID: <input type="text" name="StudID" /><br/>
Student Name: <input type="text" name="StudName" /><br/>
Comment 1: <input type="text" name="Com1" /><br/>
Comment 2: <input type="text" name="Com2" /><br/>
Comment 3: <input type="text" name="Com3" /><br/>
Comment 4: <input type="text" name="Com4" /><br/>
<input type="submit" value="Submit Form">
</form>
</body>
</html>
Я использую класс Кевина для записи данных CSV.php
вот мой php
<?php
require_once 'CSV.php';
$out_file = 'learning_goals.csv';
$csv = new CSV();
$headers = array ( // one row
array ( // six columns
'StudID',
'StudName',
'Com1',
'Com2',
'Com3',
'Com4'
)
);
if ( !is_file( $out_file ) ) {
$csv->write_table( $headers, $out_file );
}
$data = array ( // one row
array ( // six columns
$_POST['StudID'],
$_POST['StudName'],
$_POST['Com1'],
$_POST['Com2'],
$_POST['Com3'],
$_POST['Com4']
)
);
$csv->append_table( $data );
// now you have a csv file in the same directory as this script
// you can read and edit it with excel, or also this class
// ... for demonstration purposes ...
// comment out the following for production
$table = $csv->parse_table();
print_r ( $table );
?>
Я новичок в CSV, я только что создал CSV-файл с именем learning_goals.csv и создал 5 входных данных "StudID", "StudName", "Com1", "Com2", "Com3", "Com4"
Когда я ввожу свои данные и нажимаю на них, отображается
Примечание: неопределенное свойство: CSV :: $ csv_file в /opt/lampp/htdocs/data-export/CSV.php в строке178 НЕ МОЖЕТ ПРИЛОЖИТЬ К ФАЙЛУ CSV
Кто-нибудь знает, как я могу решить эту проблему?