我有一個數據庫,如果可能的話,我想以數值數組的形式獲取一列。訪問PHP中的特定列
這是我的代碼,但我只能得到第一項。
<?php
$dbc = mysqli_connect('localhost', 'starCreator', 'starCreatorPass','starsystem') or die ('starCreator: ... I couldn.t connect to the database, something is wrong with the authentication'.'<br />');
if ($dbc)
{
echo 'starCreator: ... connection to the database is established'.'<br/>';
}
$query = "SELECT name FROM stars";
$result = mysqli_query($dbc,$query);
$row = mysqli_fetch_array($result, MYSQLI_NUM);
echo $row[0];
echo $row[1];
?>
此行[1]不會重試第二項。
您確定查詢返回多於1行? – KAD
如果你的意思是查詢本身?然後是 - 我使用終端嘗試了這個命令。 –
好吧,那麼你有一些正確的答案:) – KAD