打印出存储在数据库中的信息时遇到问题。我已经使用数组将多个条目插入到单个表单中,但是一旦信息成功存储到数据库中并且我尝试检索数据,我就无法看到任何信息。它似乎完全空白。下图显示了插入表单的数据。有多个条目都分配到一个数组中。然后拆分数组并重新插入数据库。
http://oi66.tinypic.com/r89xjl.jpg
下一张图片显示在进入数据库后从表单中检索的数据(数据库内的数据也如下所示) -
http://oi63.tinypic.com/n5nghy.jpg(正在检索的表单中的数据“editjapplications.php?id = 1”)
http://oi68.tinypic.com/2csgqaf.jpg(原始形式的MySQL数据库)
http://oi68.tinypic.com/2m5gm8l.jpg(包含三个条目的MySQL数据库)
http://oi67.tinypic.com/oswtbc.jpg(从表单字段中检索后返回空格 - “editjapplications.php?id = 1”)
这是返回空格的代码,如上一张图片中所示(这句话正上方) -
<?php
$query33 = "SELECT * FROM emprecords WHERE id ='$id'";
$record_set33 = $dbs->prepare($query33);
$record_set33 -> execute();
$row22 = $record_set33->fetch(PDO::FETCH_ASSOC);
$id=$row22["id"];
$first_name=$row22["first_name"];
$middle_names1=$row22["middle_names"];
$last_name=$row22["last_name"];
$full_names = $first_name." ".$middle_names." ".$last_name;
$idz = $_GET["idz"];
//$_SESSION["idz"] = $idz;
//$query = "SELECT * FROM emprecords WHERE id ='$id'";
//$record_set = $dbs->prepare($query);
//$record_set -> execute();
//$row = $record_set->fetch(PDO::FETCH_ASSOC);
echo "<table border='1' align='center' cellspacing='0' style='margin-top:22px width='900'>
<colgroup>
<col span='2'>
</colgroup>";
$full_names1 = $_GET["full_name"];
$query11 = "SELECT * FROM education WHERE full_name ='$full_names1' AND idz='$idz'";
$listAHI2 = $dbs ->prepare($query11);
$listAHI2 -> execute();
while ($row22 = $listAHI2 ->fetch(PDO::FETCH_ASSOC));
$full_names1 = $row22["full_name"];
$name_1 = $row22["name_1"];
$idz = $row22["idz"];
echo $full_names;
echo $name_1;
echo $idz;
$institution_1 = $row22["institution_1"];
echo $institution_1;
$instaddress_1 = $row22["instaddress_1"];
echo $instaddress_1;
$monthto_1 = $row22["monthto_1"];
echo $monthto_1;
$toyear_1 = $row22["toyear_1"];
$monthto_1_1 = $row22["monthto_1_1"];
$toyear_1_1 = $row22["toyear_1_1"];
$graduate_1 = $row22["graduate_1"];
$averages_1 = $row22["averages_1"];
echo "<tr>";
echo "<td valign='top'><input type='input' id='name_1' name='name_1[]' value='$name_1' maxlength='30' size='20'><td>";
echo "<td><select name='institution_1[]' id='institution_1'> <option>$institution_1</option>";
$sql1a = "SELECT * FROM institution ORDER BY institution asc";
$smt1a = $dbs->prepare($sql1a);
$smt1a -> execute();
while($row1a=$smt1a->fetch(PDO::FETCH_ASSOC))
{
if($row1a['institution']==$_GET['id3'])
echo("<option selected value=$row1a[institution]>$row1a[institution]</option>");
else
echo("<option value=$row1a[institution]>$row1a[institution]</option>");
}
echo "<select></td>";
echo "<td valign='top'><input type='text' id='instaddress_1' name='instaddress_1[]' value='$instaddress_1' maxlength='15' size='15'><td>";
echo "<td><select name='monthto_1[]' id='monthto'> <option>$monthto_1</option>";
$sql1a = "SELECT * FROM month ORDER BY id";
$smt1a = $dbs->prepare($sql1a);
$smt1a -> execute();
while($row1a=$smt1a->fetch(PDO::FETCH_ASSOC))
{
if($row1a['month']==$_GET['id4'])
echo("<option selected value=$row1a[month]>$row1a[month]</option>");
else
echo("<option value=$row1a[month]>$row1a[month]</option>");
}
echo "</select></td>";
echo "<td><select name='toyear[]' id='toyear'> <option>$toyear_1</option>";
$sql1a = "SELECT * FROM year ORDER BY year desc";
$smt1a = $dbs->prepare($sql1a);
$smt1a -> execute();
while($row1a=$smt1a->fetch(PDO::FETCH_ASSOC))
{
if($row1a['year']==$_GET['id5'])
echo("<option selected value=$row1a[year]>$row1a[year]</option>");
else
echo("<option value=$row1a[year]>$row1a[year]</option>");
}
echo "</select></td>";
echo "<td><select name='monthto1[]' id='monthto1'> <option>$monthto_1_1</option>";
$sql1a = "SELECT * FROM month ORDER BY id";
$smt1a = $dbs->prepare($sql1a);
$smt1a -> execute();
while($row1a=$smt1a->fetch(PDO::FETCH_ASSOC))
{
if($row1a['month']==$_GET['id6'])
echo("<option selected value=$row1a[month]>$row1a[month]</option>");
else
echo("<option value=$row1a[month]>$row1a[month]</option>");
}
echo "</select></td>";
echo "<td><select name='toyear1[]' id='toyear1'> <option>$toyear_1_1</option>";
$sql1a = "SELECT * FROM year ORDER BY year desc";
$smt1a = $dbs->prepare($sql1a);
$smt1a -> execute();
while($row1a=$smt1a->fetch(PDO::FETCH_ASSOC))
{
if($row1a['year']==$_GET['id7'])
echo("<option selected value=$row1a[year]>$row1a[year]</option>");
else
echo("<option value=$row1a[year]>$row1a[year]</option>");
}
echo "</select></td>";
echo "<td>$graduate_1<td>";
echo "<td valign='top'><input type='text' id='averages' name='averages[]' value='$averages_1' maxlength='100' size='3'></td>";
$query = "SELECT * FROM education WHERE full_name ='$full_name'";
$listAHI = $dbs ->prepare($query);
$listAHI -> execute();
while($row = $listAHI ->fetch(PDO::FETCH_ASSOC)){
$idz = $row["idz"];
echo "<td> <a href='editeducation.php?full_name=$full_name&idz=$idz' name='Edit' value='Edit'>Edit</a></td>";
echo "<td> <a href='deleteeducation.php?full_name=$full_name&idz=$idz' name='Delete' value='Delete'>Delete</a></td>";
echo "<td valign='top'> <a href='deleteedcuation'name='delete' value='Delete'</a></td>";
}
echo "</tr>";
echo "</table>";
?>
我的代码在哪里出错了?为什么不从数据库返回数据?它应该在表单字段下面的列中打印出3行数据。它甚至不包含1行单行数据。数据已在所有正确的字段中成功输入数据库,如上面的屏幕截图所示(http://oi68.tinypic.com/2m5gm8l.jpg)。
当我尝试通过转到链接 - “editjapplications.php?id = 1”来检索表单详细信息时,为什么数据没有显示我很困惑 - 尽管所有数据都已输入到各个字段中并且应该在该页面上显示所有3行 - 但是甚至没有显示一行数据!
我错过了什么?
答案 0 :(得分:0)
要调试所有的PHP代码,请将其添加到PHP代码的最顶层(在开头标记之后):
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
这将显示您的PHP代码中的错误。