duanjiu6697 2013-09-24 10:47
浏览 21

UPDATE查询的增量不超过4

I have another problem which I have spent hours on understanding and rewriting. On the UPDATE query I included countr=countr+1. I successfully received the keyWords from the mobile application and was also able to store them in the database. The problem is, whenever the same keyWord is passed for the fifth time a new row is created. Instead of adding 1 to the countr of that keyWord. It's as if the countr is limited on holding number 4 only.

Is it because of a mistake I did with the UPDATE query or is it because of something else I missed?

Here is my code:

$con= mysqli_connect("...","...","...") or die ('Error: ' . mysql_error()); 
mysqli_select_db($con,"...");
$sql= "SELECT keyWord FROM searchedWords";
$result= mysqli_query($con,$sql);
$row=mysqli_fetch_array($result, MYSQLI_ASSOC);

if($row['keyWord']==$_POST[keyWord])
{
  $upD="UPDATE searchedWords SET countr = countr + 1";
     while (!mysqli_query($con,$upD))
    {
     die('Error: ' . mysqli_error($con));
    }
}
else
{
   $insertIn="INSERT INTO `searchedWords`( `keyWord`, `countr`) values ('$_POST[keyWord]',1)";
 while (!mysqli_query($con,$insertIn))
    {
     die('Error: ' . mysqli_error($con));
    }
}

Here is the table where the keyWords and countr are stored:

the DB table

It just wont go over 4. Android should have a countr of 9 and Java 5. What do you think did I do wrong?

  • 写回答

2条回答 默认 最新

  • dongshan9619 2013-09-24 11:03
    关注
    $_POST[keyWord] 
    

    should be

    $_POST['keyWord']
    
    评论

报告相同问题?

悬赏问题

  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 个人网站被恶意大量访问,怎么办
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制