English 中文(简体)
如何从动态表格中插入插入?, 从. xml 文件 PHP 读取
原标题:How make a insert from dynamic table?, reading from .xml file PHP

我需要帮助在我的 DB ( Mysql) 中插入一个表格。 表格创建时读取了. xml 文件, 行数取决于. xml 文件的阵营数量, 下面的代码与我打印结果的方式相符 。

有几个人问我 使用读.xml的代码, 我希望帮助我弄清楚 如何插入

 <?php require_once( Connections/conection_siipo.php ); ?>
  <?php

  $data = 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;
      }
      }

?>

HTML HTML

<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>

此代码是数据的结果, 所以我需要帮助在我的 DB 中插入一个字 :

<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>

我怎样才能保存表格的内容, 因为有时.xml文件有100行以上?

如何从动态表格中插入插入?, 从. xml 文件 PHP 读取

问题回答




相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签