2016-05-13 28 views
0

我正在處理一個項目,並且遇到了一個小問題。我想向存儲在mySQL中的表中的所有者顯示一個請求。第一個條目很好。但是第二個條目在第一個條目旁邊而不是在下面。所以它看起來像這樣 標題標題標題標題 值值值第2值第2值第2值第2值。 我怎樣才能解決這個問題,並把相應的報頭下方的第二個值和value.Here是我的代碼HTML PHP在不同行中輸入表格的條目

<table border='1' cellpadding='5'>" 
    <title>View Incoming Orders</title> 
    <tr> <th>Restaurant Name</th> 
    <th>Customer</th> 
    <th>Order Date</th> 
    <th>Details</th> 
    <th>Cost</th> 
    <th>is Processed</th> 
    <th> Finalize Order </th> 
    <th> Delete </th> 

    </tr> 
    <tr> 
    <?php 
     $length=count($restaurantNames); 
      for($c=0; $c<$length; $c++){ 
      $custDate=$customers[$c]. "/".$orderDates[$c]; 
      echo "<td> $restaurantNames[$c]</td>"; 
      echo "<td> $customers[$c]</td>"; 
      echo "<td> $orderDates[$c]</td>"; 
      echo "<td> $detailss[$c]</td>"; 
      echo "<td> $costs[$c]</td>"; 
      echo "<td> $isProcesseds[$c]</td>"; 
      echo "<td><input type='checkbox' name='check_list[]' value='$custDate' />Finalize Order </td>"; 
      echo "<td><input type='checkbox' name='check_list2[]' value='$custDate' />Delete </td>"; 

      } 

     ?> 
    </tr> 
    <tr><input type="submit" id="update" name="update" value="Update"></input></tr> 
    </table> 

回答

2

請嘗試移動tr進入循環,而不是在它之外。另外title對於您如何使用它無效。它的目的是爲網站的標題標籤中head

<table border='1' cellpadding='5'>" 
    <title>View Incoming Orders</title> 
    <tr> <th>Restaurant Name</th> 
    <th>Customer</th> 
    <th>Order Date</th> 
    <th>Details</th> 
    <th>Cost</th> 
    <th>is Processed</th> 
    <th> Finalize Order </th> 
    <th> Delete </th> 

    </tr> 
    <?php 
     $length=count($restaurantNames); 
      for($c=0; $c<$length; $c++){ 
echo "<tr>"; 
      $custDate=$customers[$c]. "/".$orderDates[$c]; 
      echo "<td> $restaurantNames[$c]</td>"; 
      echo "<td> $customers[$c]</td>"; 
      echo "<td> $orderDates[$c]</td>"; 
      echo "<td> $detailss[$c]</td>"; 
      echo "<td> $costs[$c]</td>"; 
      echo "<td> $isProcesseds[$c]</td>"; 
      echo "<td><input type='checkbox' name='check_list[]' value='$custDate' />Finalize Order </td>"; 
      echo "<td><input type='checkbox' name='check_list2[]' value='$custDate' />Delete </td>"; 
echo "</tr>"; 
      } 

     ?> 

    <tr><input type="submit" id="update" name="update" value="Update"></input></tr> 
    </table> 
+0

這works.I我接受它作爲一個answer.But我覺得標題可以這樣的工作,因爲它是在我管理現場工作 – Curriculaa