How make a insert from dynamic table?, reading from .xml file PHP

Sidwayabanify

New Member
I need help inserting a table in my DB (mysql). The table was created reading a .xml file, the number of rows depends the number of camps the .xml file had, the code below correspond how i print the results.a couple people ask me for the code im using the read the .xml here it is, i hope help me to figure it out how to make the insert\[code\] <?php require_once('Connections/conection_siipo.php'); ?> <?php $data = http://stackoverflow.com/questions/10721987/array(); function add_person( $operation, $description, $zone, $workshop ) { global $data; $data []= array('operation' => $operation, 'description' => $description, 'zone' => $zone, 'workshop' => $workshop ); } if ( $_FILES['file']['tmp_name'] ) { $dom = DOMDocument::load( $_FILES['file']['tmp_name'] ); $rows = $dom->getElementsByTagName( 'Row' ); $first_row = true; foreach ($rows as $row) { if ( !$first_row ) { $operation = ""; $description = ""; $zone = ""; $workshop = ""; $index = 1; $cells = $row->getElementsByTagName( 'Cell' ); foreach( $cells as $cell ) { $ind = $cell->getAttribute( 'ss:Index' ); if ( $ind != null ) $index = $ind; if ( $index == 1 ) $operation = $cell->nodeValue; if ( $index == 2 ) $description = $cell->nodeValue; if ( $index == 3 ) $zone = $cell->nodeValue; if ( $index == 4 ) $workshop = $cell->nodeValue; $index += 1; } add_person( $operation, $description, $zone, $workshop ); } $first_row = false; } }?>\[/code\]HTML \[code\]<table> <tr> <th>Operation</th> <th>Description</th> <th>Zone</th> <th>Workshop</th> </tr> <?php foreach( $data as $row ) { ?> <tr> <td><?php echo( $row['operation'] ); ?></td> <td><?php echo( $row['description'] ); ?></td> <td><?php echo( $row['zone'] ); ?></td> <td><?php echo( $row['workshop'] ); ?></td> </tr> <?php } ?></table>\[/code\]This code is the result of the data, so i need help to build a insert in my DB: \[code\]<table> <tr> <th>Operation</th> <th>Description</th> <th>Zone</th> <th>Workshop</th> </tr> <tr> <td>LAN_CQM_CHK_T001BE1N_2</td> <td>200002-01-1-REINS(JIC) (GENERAL VISUAL INSPECTION OF ELEMENTS FITTED ON THE FOLLOWING HARNESSES: 400VB, 401VB, 402VB, 403VB, 404VB, 405VB, 406VB, 407VB, 408VB, 409VB)</td> <td>300</td> <td>40</td> </tr> <tr> <td>LAN_CQM_CHK_T001BE1M_3</td> <td>200002-01-1-REM(JIC) (GENERAL VISUAL INSPECTION OF ELEMENTS FITTED ON THE FOLLOWING HARNESSES: 400VB, 401VB, 402VB, 403VB, 404VB, 405VB, 406VB, 407VB, 408VB, 409VB)</td> <td>300</td> <td>40</td> </tr> <tr> <td>LAN_CQM_CHK_T001BK4W_4</td> <td>200315-01-1-INSP(JIC) (GENERAL VISUAL INSPECTION OF G AND P ROUTE WIRING INSTALLED IN THE TAIL CONE AND APU ACCESSORY COMPARTMENT)</td> <td>300</td> <td>34</td> </tr> <tr> <td>LAN_CQM_CHK_T001BK56_5</td> <td>200413-01-1-ENG2-INSP(JIC) (DETAILED INSPECTION OF ALL WIRING INSTALLED IN THE UPPER FORWARD PYLON)</td> <td>400</td> <td>34</td> </tr> <tr> <td>LAN_CQM_CHK_T001FX2Z_6</td> <td>200413-03-1-ENG1-INSP(JIC) (DETAILED INSPECTION OF EWIS INSTALLED IN THE UPPER FORWARD PYLON (EWIS))</td> <td>400</td> <td>40</td> </tr> <tr> <td>chong</td> <td>200413-03-1-ENG2-INSP(JIC) (DETAILED INSPECTION OF EWIS INSTALLED IN THE UPPER FORWARD PYLON (EWIS))</td> <td>400</td> <td>40</td> </tr>\[/code\]How can I save the content of the table, cause sometimes the .xml file have more than 100 rows? How make a insert from dynamic table?, reading from .xml file PHP
 
Back
Top