0
我能够从我的数据库中获取数据并使用php显示它们。 我想知道如何获取包含数据的表的列名称?或者是否有其他方法可以用来将亲友的姓名与亲属姓名一起显示?提取列表名称
在此刻我缓存表中这样说:
<?php
$connection = mysql_connect('x ', 'x ', ' x');
mysql_select_db('x');
$query = "SELECT * FROM trip";
$result = mysql_query($query);
echo "<table >";
while($row = mysql_fetch_array($result)){
if ($row['Day'] == date("Y-m-d"))
{
echo '<tr class="today">';
}
else {echo "<tr>"; }
echo "<td>" . $row['Day'] . "</td>
<td>" . $row['Country'] . "</td>
<td>" . $row['Place'] . "</td>
<td>" . $row['Flight'] . "</td>
</tr>"; //$row['index'] the index here is a field name
}
echo "</table>"; //Close the table in HTML
mysql_close(); //Make sure to close out the database connection
?>
您使用的是什么查询?你在你的select语句中指定了列名,还是使用'*'? – 2015-02-12 01:52:58
另一种方法是使用你现在拥有的东西,通过assoc获取,然后得到这些数组键,或者是最直接的方式'DESCRIBE',然后获取。 – Ghost 2015-02-12 01:57:15
问题更新 – gigi 2015-02-12 02:12:48