我必须从别人制作的表格中取出并将其打印到网页上。问题是,该列名存储在行中。例如:
FIELD_NAME| FIELD_VALUE
______________________
first-name| John
last-name | Smith
这就是我要获取数据的方式
$tableRow = '';
$sql ="SELECT * FROM `wp_cf7dbplugin_submits` WHERE form_name = '".$nameOfForm."' ";
$result = $mysqli->query($sql);
while($tableData = $result->fetch_assoc()){
$fieldName = $tableData['field_name'];
$fieldValue = $tableData['field_value'];
//FIRST NAME
if($fieldName == 'first-name'){
$firstName = $fieldValue;
}
//LAST NAME
if($fieldName == 'last-name'){
$lastName = $fieldValue;
}
//BUILD A ROW FOR THE TABLE
$tableRow .='
<th>'.$firstName.'</th>
<th>'.$lastName.'</th>
';
}
当我这样做时  ,它只会显示一个结果,$tableRow =而不是  $tableRow .=
它只会显示一个结果,但是当我这样做时,$tableRow .=它只会显示空的但正确数量的 s。
如何使用从这样的表中提取的所有结果填充 html 表?
编辑:我忘了提到整个表是这样的:
<table id="theTable">
            <thead>
                <tr>
                    <th style="width:100px;">First Name</th>
                    <th style="width:100px;">Last Name</th>
                </tr>
            </thead>
            <tbody id="rowsGoHere">
            </tbody>
        </table>
我通过 ajax 回显 PHP 结果,
//ECHO BACK RESULTS
    $JSONData = array("true", $tableRow); 
    echo $_GET['callback']."(".json_encode($JSONData).")";
并用它来插入表格
var trueEncV = encodeURIComponent("true");
                $.getJSON("pullTableData.php?callback=?",
                      {
                        trueV: trueEncV
                      }, 
                      function(dataBack){
                        alert(dataBack);
                        $('#rowsGoHere').html(dataBack[1]);
                    }
                )
这一切都很好,花花公子。