$sql = "SELECT * FROM
fbr.*, c.sample, ci.dob, ci.country, ci.sex
FROM `finalBloodReport` fbr ,`clients` c, `client_info` ci
WHERE fbr.sampleSerialNo = (CONCAT(c.resellerSerialId,'-',c.kitSerialNo) )
AND c.client_id = ci.id";
这是我的查询它工作正常并提供所需的输出,但由于我在表中显示数据,我还希望仅为此查询获取列名称以将其显示为表标题。 < / p>
我试过像这样的东西,但结果为空。
$sql = "SHOW COLUMNS
fbr.*, c.sample, ci.dob, ci.country, ci.sex
FROM `finalBloodReport` fbr ,`clients` c, `client_info` ci
WHERE fbr.sampleSerialNo = (CONCAT(c.resellerSerialId,'-',c.kitSerialNo) )
AND c.client_id = ci.id";
有人可以帮忙吗?我对mysql不太满意; (
答案 0 :(得分:0)
执行查询后需要检索列信息。这可以通过mysqli_fetch_field()
您的代码应如下所示
$result = mysqli_query($sql);
while($field = mysqli_fetch_field($result)) {
print $field->name . "\t";
}
while ($row = mysqli_fetch_row($result) {
print_r($row);
}