我有数据库,其中有五个项目是通过用户名添加的。当我想按用户获取项目时,只返回一个项目。
<?php
require_once("db.php");
$db = DB();
$query = $db->prepare("SELECT * FROM projects WHERE username='$username'");
$query->execute();
$row = $query->fetch();
$name = $row['name'];
$project = $row['project'];
echo "<p>Project name: $name</p>
<p>Project: $project</p>
?>