0
即時試圖從我的數據庫(文章)和表文章中提取一張表,並將其放入數組中,但即時通訊不知道天氣與否因爲我不知道如何打印數組。我正在關注這個鏈接。從數據庫中提取數組php
<?php
$servername = "localhost";
$username = "username";
$password = "password";
// create connection
$conn = new mysqli($servername, $username, $password);
// check connection
if ($conn->connect_error){
die("connection failed: " . $conn->connect_error);
}
// connect to DB
$db_selected = mysqli_select_db('article', $conn);
if (!$db_selected){
die("can't use article : " .mysqli_error());
}
// extract databases table to PHP array
$query = "SELECT * FROM `articles`";
$result = mysqli_query($query);
$number = mysql_numrows($result);
$article_array = array();
$x = 0
while($x < $number)
{
$row = mysqli_fetch_array($result);
$artic = $row['name'];
$amount = $row['quantity'];
$article_array[$artic] = $amount;
$x++;
}
echo count($article_array);
//echo "hello";
<?
即使回聲你好不會工作和IM不知道如果我應該把一個名稱和數量:
$artic = $row['name'];
$amount = $row['quantity'];
你說'echo「hello」;'不工作?你有沒有php服務器?你在工作什麼服務器? xampp,wamp還是lamp? –
沒有'mysql_numrows'函數。 mysqli_和mysql_函數是**不同的** API。什麼是結尾'<?'? –