这是我的代码
<?php
session_start();
include 'header.php';
$getUserInfo = mysql_query("SELECT * FROM Campaigns WHERE cid = '$cid'");
$userinfo = mysql_fetch_assoc($getUserInfo);
$cid = $getUserInfo['cid']; //ID
$CName = $getUserInfo['CName']; //Name
$CDesc = $getUserInfo['CDesc']; //Description
$CAmt = $getUserInfo['CAmt']; //Rate
$CReqs = $getUserInfo['CReqs']; //Requirements
?>
<html>
<body>
<h3><?php echo $cid;?>, <?php echo $CName;?></h3>
<p><?php echo $CDesc;?>
</body>
</html>
对于php数据库中的每个新项目,我希望它动态显示。
但由于某些原因,没有显示任何信息。是因为我正在使用getUserInfo
答案 0 :(得分:2)
替换
$cid = $getUserInfo['cid']; //ID
$CName = $getUserInfo['CName']; //Name
$CDesc = $getUserInfo['CDesc']; //Description
$CAmt = $getUserInfo['CAmt']; //Rate
$CReqs = $getUserInfo['CReqs']; //Requireme
与
$cid = $userinfo ['cid']; //ID
$CName = $userinfo ['CName']; //Name
$CDesc = $userinfo ['CDesc']; //Description
$CAmt = $userinfo ['CAmt']; //Rate
$CReqs = $userinfo ['CReqs']; //Requireme
您正在阅读错误的变量
进一步的建议:
确保您确实从MySQL获得结果:
var_dump($getUserInfo);
var_dump($userinfo);
如果没有,请使用echo mysql_error();
确保数组中有正确的键(PHP变量区分大小写)