2015-04-26 47 views
0

所以我有這樣的代碼應該打印一堆盒裝在結果中,應該作爲窗體來獲取任何用戶的數據,但是當我存儲一個巨大的html字符串一個變量,然後打印到我的HTML,它只附加一個框的表單標籤一次。這是爲什麼發生?這對我來說似乎不合邏輯。這是我與我的代碼完成:使用echo在PHP中使用PHP打印多個表格

<?php 
    if($searchData == "" || $resultArray == null){ 
     echo "<h2>No results found<h2>"; 
    } else { 
     foreach($resultArray as $iterator){ 
      $finalResult = $finalResult.'<div class="col-lg-4 col-sm-6"> 
              <div class="properties"> 
               <form action="user-detail.php" method="POST"> 
                <h4>'.$iterator['USERNAME'].' </h4> 
                <h5>'.$iterator['PERSON_NAME'].'</h5> 
                <h5>'.$iterator['FIRST_LAST_NAME'].'</h5> 
                <h5>'.$iterator['SECOND_LAST_NAME'].'</h5> 
                <input class="form-control" type="text" style="display: none" readonly name="username" value="'.$iterator['USERNAME'].'"/> 
                <input class="form-control" type="text" style="display: none" readonly name="p_id" value="'.$iterator['PERSON_ID'].'"/> 
                <input class="form-control" type="text" style="display: none" readonly name="name" value="'.$iterator['PERSON_NAME'].'"/> 
                <input class="form-control" type="text" style="display: none" readonly name="last_name" value="'.$iterator['FIRST_LAST_NAME'].'"/> 
                <input class="form-control" type="text" style="display: none"readonly name="second_last_name" value="'.$iterator['SECOND_LAST_NAME'].'"/> 
                <input class="form-control" type="text" style="display: none" readonly name="b_value" value="'.$iterator['BLACKLIST'].'"/> 
                <input type="submit" class="btn btn-primary" value="View Details" 
               <form/> 
              </div> 
              </div>'; 
     } 
     echo $finalResult; 
    } 
?> 

通常情況下,我也不會要求這方面的幫助,但我不知道爲什麼這樣的錯誤可能發生。至於爲什麼會發生,這對我來說毫無意義。如果有人能澄清爲什麼會發生這種情況,我將不勝感激。

回答

1

您的結尾表單標記格式不正確。

您有:<form/>

它應該是:</form>

我希望幫助!

+0

不,不是。我希望它一直是。 – Argus

+0

您的提交按鈕也缺少右括號。

+0

是的。謝謝,我不能相信我錯過了這樣的事情。我一直在做這個愚蠢的項目太久。 – Argus