2016-09-26 2 views
0

私は簡単な質問がありますが、基本的にいくつかのコードを書いています。 HTMLは ..私はテーブルフッタそしてhtmlの、その後、表示したい ...最初にしてフッタして、テーブルを表示しているここに私のコードhtmlの前にphpコードを表示するにはどうすればいいですか?

if($orderCount == 0){ 
echo "<p><strong> No orders pending. Please try again later.</strong></p>"; 
    } 
echo "<table border=\"1\">\n"echo "<tr> <th bgcolor=\"blue\"> Order Summary</th></tr> 
<tr> <th bgcolor=\"blue\"> Title</th> 
    <th bgcolor=\"blue\"> Author</th> 
    <th bgcolor=\"blue\"> Format</th> 
    <th bgcolor=\"blue\"> Price</th> 
    </tr>"; 


    for($i=0;$i<$orderCount;$i++){ 

echo "<tr> 
    <td> $titleArray[$i]</td> 

      <td>$authorArray[$i]</td> 
       <td>$formatArray[$i]</td> 
        <td> $$priceArray[$i]</td> 
         </tr>"; 


} 
$total = number_format(array_sum($priceArray),2); 
echo " <tr> <td bgcolor=\"blue\"> Total price</td><td>&nbsp</td> <td>&nbsp</td><td align=\"right\">$$total</td></tr>" 


    ?> 
     <form action="myform.php" method="post"> 
     <ul> 
     <li>Payment Information</li> 

     </ul> 
     <label for="customer name">Customer Name</label> 
     <input type="text" name="customername" id="customername"> <br /> 
     <label for="address">Street Address</label> 
     <input type="text" name="city" id="city"> <br /> 
     <label for="state">State</label>   
     <input type="text" name="state" id="state"> <br /> 
     <label for="zip">Zip Code</label> 
     <input type="text" name="zip" id="zip"> <br /> 
     <input type="submit" value="Confirm Order"> 

    </form> 

</body> 
+1

のようなHTMLを行うことができます。 –

+1

...最初のヘッダーを印刷した後、テーブル行「」を閉じています...実際に開いているタグと閉じるタグを確認する必要があります... –

+0

...また、 '$$ total'のようなドル記号。それは意図的なのでしょうか?あなたは本当にあなたのコードをより良く構造化し、それを見てすべてのエラーをキャッチしようとするべきです。 –

答えて

1

はあなたがob_get_contents()機能を使用する必要があります。

+0

彼は実際に正しい順序ですべてを印刷しているのであれば、なぜそれを使うべきですか?彼のコードは、不一致のHTMLタグの遊び場であり、ob_get_contents()が修正するものではありません。 –

1

あなただけのPHP取得し、あなたがテーブルタグ ``あなたがそれで行われたときに、それは良い仕事かもしれないが閉じた場合、この

<?php 
     // some php code you had 

?> 
    your html 
    <?php 
    // resume php code 
?> 
関連する問題