我是一個PHP和MySQL的noob。我正在尋找一種方法來訪問我的數據庫中的表格,並以行格式獲取數據。我發現以下代碼:有沒有一種方法來定義在API中的表名稱Url
<?php
$con = mysql_connect("localhost","someuser","somepassword");
if (!$con)
die('Could not connect: ' . mysql_error());
mysql_select_db("TestDatabase", $con);
$result = mysql_query("SELECT * FROM Customer");
$output = array();
if ($result)
while ($row = mysql_fetch_assoc($result))
$output[] = $row;
print(json_encode($output));
mysql_close($con);
?>
現在的問題是我有大約超過24個表在我的數據庫。所以我希望有沒有辦法通過像API這樣的訪問URL輸入表的名稱。如果有,那麼請幫助我。提前致謝!!!
爲喜炎我已經創建了一個API,它的網址是這樣的: HTTP://mywebsite/api/folder/index.php 但每當我嘗試訪問它,它給了我一個錯誤。你能幫忙嗎? –
最有可能的錯誤是有關服務器/ php錯誤配置... – bbonev