thenorman138 Posted May 2, 2017 Share Posted May 2, 2017 I have an upload page that users for a small company use to upload/submit csv sheets daily. They are always the same, 235 fields in the same order. I currently have a preview button that shows the CSV in a table/form (for edits) and a submit button that has been successfully inserting the CSV into a 235 field staging table in the database. I now need to submit the preview form/table with any edits the user might make. I added a 'Submit' button to the preview form, but I haven't gotten it to work yet. I have an array that works on the first page, taking all 235 fields and naming them to either insert into the database or display in the preview table. In order to submit from the table, including any edits that were made, I think I need to create a new CSV from the html form/table and insert that similarly, but I've never done this and I'm unsure now. This is the code for the preview form that is built from the CSV that is uploaded: if(isset($_POST['preview'])) { ini_set('auto_detect_line_endings', true); $file = $_FILES["file"]["tmp_name"]; $handle = fopen($file, "r"); $maxPreviewRows = PHP_INT_MAX; // this will be ~2 billion on 32-bit system, or ~9 quintillion on 64-bit system $hasHeaderRow = true; echo '<table>'; /*WE WILL NEED TO QA CONDITIONS AND HIGHLIGHT IN RED HERE. ALSO NEED BORDER STYLINGS*/ if ($hasHeaderRow) { $headerRow = fgetcsv($handle); echo '<thead><tr>'; foreach($headerRow as $value) { echo "<th>$value</th>"; } echo '</tr></thead>'; } echo '<tbody>'; $rowCount = 0; while ($row = fgetcsv($handle)) { echo '<tr>'; foreach($row as $value) { echo "<td>$value</td>"; } echo '</tr>'; if (++$rowCount > $maxPreviewRows) { break; } } echo '</tbody></table>'; } ?> Quote Link to comment Share on other sites More sharing options...
benanamen Posted May 2, 2017 Share Posted May 2, 2017 (edited) a 235 field staging table in the database. Oh say it's not so. A database is not a spreadsheet. I would want to see one of these 235 field files before I could tell you how to go about this. If you can, attach or Pm the file. I only need to see a couple rows of data with headers. What you need is an ETL process (Extract, Transform, Load). https://en.wikipedia.org/wiki/Extract,_transform,_load Edited May 2, 2017 by benanamen Quote Link to comment Share on other sites More sharing options...
thenorman138 Posted May 2, 2017 Author Share Posted May 2, 2017 (edited) I know it's not great, but unfortunately a very outdated utilities system is being used and this is how I've been tasked to do it. I'm splitting everything into smaller tables, but it hits the staging table first. Sorry, did you want me to post one of the CSV files that's being uploaded initially? Or am I posting something different? Edited May 2, 2017 by thenorman138 Quote Link to comment Share on other sites More sharing options...
benanamen Posted May 2, 2017 Share Posted May 2, 2017 (edited) I would like to see the initial file. Some details of the common edits would be helpful and details on how the data is generated in the first place. A brief summary of what this is all about and how it will be used would be helpful as well. Think as though nothing exists and we needed to develop a system from scratch to accomplish your purposes. Edited May 2, 2017 by benanamen Quote Link to comment Share on other sites More sharing options...
thenorman138 Posted May 2, 2017 Author Share Posted May 2, 2017 Gotcha. Can I PM you or email you with files? Quote Link to comment Share on other sites More sharing options...
benanamen Posted May 2, 2017 Share Posted May 2, 2017 If you can't PM my email is in my profile. Quote Link to comment Share on other sites More sharing options...
thenorman138 Posted May 2, 2017 Author Share Posted May 2, 2017 Thanks very much, I just emailed you. It doesn't look like I can PM. Please let me know if any of that is unclear. Also, the PHP file I attached has the submit code as well so it's pretty lengthy, but the code for the preview window is near the top Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.