-7

我想从我的数据库中选择一个表,但我不知道该怎么做,而且我不擅长搜索谷歌。我现在拥有的代码:
$query = "SELECT * FROM table";

echo $query;

谁能帮我?谢谢

编辑:我正在使用 PDO 进行连接

4

1 回答 1

2

尽管您可以在网络上随处找到它。这是在表中显示数据库中数据的基本代码:

require ('connection_to_db.php'); 

try {

$sql = "SELECT * FROM table";
$result = $pdo -> query($sql);
$result->execute(); 
}

catch(PDOException $e) {
    echo "Something went wrong";
$e->getMessage();
exit;
}

echo "<table width='100%' border='1'>";

while($row = $result -> fetch() ) {
    echo "<tr>";
    echo "<td>".$row['table']."</td>";
    echo "</tr>";
}
echo "</table>";
于 2013-10-08T12:43:33.233 回答