Home  >  Article  >  Backend Development  >  求助:关于php一段简单代码

求助:关于php一段简单代码

WBOY
WBOYOriginal
2016-06-02 11:32:28986browse

php

这是php和mysql web开发书中一个例子,目的就是把文件保存的订单信息炸开,用表格显示。我运行时为什么只显示表头,没有表格数据呢。
orders.txt中就是订单信息,用Tab分隔的,已正确读取到$orders中。貌似是后边的for循环中有问题。图片说明



Bob's Auto Parts - Customer Orders

Bob's Auto Parts

Customer Orders

//Read the entire file
//Each order becomes an element in the array
$orders = file("./orders.txt");

<code>//count the number of orders in the array$number_of_orders = count($orders);if($number_of_orders = 0) {    echo "<p><strong>No orders pending. Please try again later.</strong></p>";}echo "<table border='\"1\"'>\n";echo "<tr>
<th bgcolor='\"#CCCCFF\"'>Order Date</th>          <th bgcolor='\"#CCCCFF\"'>Tires</th>          <th bgcolor='\"#CCCCFF\"'>Oil</th>          <th bgcolor='\"#CCCCFF\"'>Spark plugs</th>          <th bgcolor='\"#CCCCFF\"'>Total</th>          <th bgcolor='\"#CCCCFF\"'>Address</th>      </tr>";for($i = 0; $i             <td>".$line[0]."</td>            <td align='\"right\"'>".$line[1]."</td>            <td align='\"right\"'>".$line[2]."</td>            <td align='\"right\"'>".$line[3]."</td>            <td align='\"right\"'>".$line[4]."</td>            <td>".$line[5]."</td>          ";}echo "</table>";</code>

?>

<code></code>

图片说明

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn