我正在尝试从dp获取更新记录的值。让我简要介绍一下 -
1.我有两个while循环,一个用于显示数据库中的记录,另一个用于在编辑操作后获取。
2.编辑了1个字段之后,记录应该在数据库中更新[我已经在db中成功更新了记录/记录]但问题是它在数据库中成功更新[因为我确实检查了我的数据库,因为我更新记录]但不显示更新记录的记录。我认为它不会进入更新查询的while循环。
请提出一些解决方案。
if(isset($_POST['recruiter_s_by_code'])
{
//some code here...the query here is being a sucesss
//SELECT STATEMENT here..
}
if(isset($_POST['recruiter_s_by_mail'])
{
//some code here...the query here is being a sucesss
//SELECT STATEMENT here..
}
if(isset($_POST['recruiter_s_by_name'])
{
//some code here...the query here is being a sucesss
//SELECT STATEMENT here..
}
if(isset($_POST['recruiter_s_by_code']) || isset($_POST['recruiter_s_by_name']) || isset($_POST['recruiter_s_by_mail']))
{
$result=mysql_query($sql);
echo "in result"
while($row=mysql_fetch_array($result))
{
$viewrecruiter0=$row['recruiter_did'];
$viewrecruiter1=$row['recruiter_name'];
$viewrecruiter2=$row['recruiter_mail'];
}
}
else
{
if(isset($_GET['var']))
{
$id1=$_GET['var'];
echo $id1;
}
//$query1=UPDATE .......SET......WHERE... ->the update too is a success for me.
$res=mysql_query($query1);
while($row=mysql_fetch_array($res))
{
$viewrecruiter00=$row['recruiter_did']; //by code
$viewrecruiter01=$row['recruiter_name'];
$viewrecruiter02=$row['recruiter_mail'];
}
}
?>
UPDATE查询运行成功,但UPDATE点击后不显示记录。仅显示标签,但不显示值。
答案 0 :(得分:2)
听起来您正在一次编辑/更新一条记录,因此请执行更新,然后在同一记录上运行选择。
//$query1=UPDATE .......SET......WHERE... ->the update too is a success for me.
$res=mysql_query($query1);
//$query1='select yada yada yada from table where SAME CONDITIONS';
$res=mysql_query($query1);
while($row=mysql_fetch_array($res)) {
如果在查询中使用$id1
,则需要将mysql_real_escape_string
放入I have anothere backup where I have used mysqli
。当你说$result = mysql_query("INSERT INTO `test1`(survey_no,lastname)
VALUES ('$survey_no','$lastname')");
$result1 = mysql_query("INSERT INTO `test2`(survey_no)
VALUES ('$survey_no')");
你应该尽可能使用mysqli而不是mysql_时,我也不清楚你的意思。