我试图通过单击表中的字段来调用phpmyadmin中存储的所有表信息。 但我遇到的ID列是主键的问题
数据控制文件:
注意:未定义的索引:第52行的C:\ xampp \ htdocs \ project \ project01 \ datacontrol.php中的ID
详细文件:
警告:mysqli_fetch_assoc()期望参数1为mysqli_result,在第22行的C:\ xampp \ htdocs \ project \ project01 \ details.php中给出的布尔值
这是表格代码:
while($record = mysqli_fetch_array($myData)) {
echo "<form action=datacontrol.php method=post>";
echo "<tr>";
echo "<td>" . "<a name style='color:black; text-decoration: none; background-color: none;'
href='details.php?id=<?php echo $record[id]?>'>" . $record['Project_Name'] ."</a>" . " </td>";
echo "<td>" . "<input type=text name=type value="
. $record['Type'] . " </td>";
echo "<td>" . "<input type=text name=cost value="
. $record['Cost'] . " </td>";
echo "<td>" . "<input type=hidden name=hidden value=" . $record['Project_Name'] . " </td>";
echo "<td>" . "<input type=submit name=update value=Update" . " </td>";
echo "<td>" . "<input type=submit name=delete value=Delete" . " </td>";
echo "</tr>";
echo "</form>";
}
echo "<form action=datacontrol.php method=post>";
echo "<tr>";
echo "<td><input type=text name=uprojectname></td>";
echo "<td><input type=text name=utype></td>";
echo "<td><input type=text name=ucost></td>";
echo "<td></td><td>" . "<input type=submit name=add value= +Add " . " </td>";
echo "</form>";
echo "</table>";
mysqli_close($con);
?>
这是我希望在单击后显示的详细信息页面:
<?php
$con = mysqli_connect("localhost", "root", "", "project");
if (!$con) {
//display the reason for mysql connection error.
die ("Connection Failed: " . mysqli_connect_errno());
}
mysqli_select_db($con, "project");
$id = $_GET['id'];
$query = 'SELECT * FROM projects WHERE id='.$id;
$result= mysqli_query($con, $query);
$record = mysqli_fetch_assoc($result);
?>
<h5><?php echo $record['projectname'];?></h5>
<br/>
<p><?php echo $record['type'];?></p>
<br/>
<?php echo $record['cost'];?>
<br/>
<?php echo $record['details'];?>
<?php
mysqli_close($con);
?>
答案 0 :(得分:0)
您已经在PHP标记内回显了。因此,无需将PHP标记放入echo中。像这样改变这行
echo "<td>" . "<a name style='color:black; text-decoration: none; background-color: none;'
href='details.php?id='.$record['id'].'>'" . $record['Project_Name'] ."</a>" . " </td>";