【发布时间】:2016-07-06 06:45:15
【问题描述】:
我正在尝试从数据库中获取单个值并将其存储在变量 Here is the structure of my Database
mysql_connect("localhost","root","") or die(mysql_error());;
mysql_select_db("test") or die(mysql_error());
$result = mysql_query('SELECT * FROM names WHERE name = noshair');
while($row = mysql_fetch_array($result));
{
echo $row['course'] . "<p>";
}
当我使用上面的代码时,它会根据我的名字从数据库打印所有课程,但我希望选择一个特定的课程名称,就像我的名字有 5 门课程一样,我只想单独保存所有课程在单独的变量中。
【问题讨论】: