Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在php中使用imagebutton更新数据库值_Php_Javascript_Jquery_Mysql_Imagebutton - Fatal编程技术网

如何在php中使用imagebutton更新数据库值

如何在php中使用imagebutton更新数据库值,php,javascript,jquery,mysql,imagebutton,Php,Javascript,Jquery,Mysql,Imagebutton,我正在处理一个php文件,winch显示了一个包含数据库值的表。每一行的末尾都有一个imagebutton,它应该会改变状态,并显示一个图像。 所以我认为它的简短功能必须是,点击go to script go to php或jQuery? 按钮还必须为下一个脚本或函数或操作系统提供用户id,还有更好的方法吗 这是我目前的基本方法,没有任何功能 在index.php中 include("function.php"); while ($row_user = mysql_fetc

我正在处理一个php文件,winch显示了一个包含数据库值的表。每一行的末尾都有一个imagebutton,它应该会改变状态,并显示一个图像。 所以我认为它的简短功能必须是,点击go to script go to php或jQuery? 按钮还必须为下一个脚本或函数或操作系统提供用户id,还有更好的方法吗

这是我目前的基本方法,没有任何功能

在index.php中

include("function.php");

while ($row_user = mysql_fetch_assoc($result_user)) {
            
    $sqle = mysql_query("
                    SELECT COUNT(*) FROM 
                       places2user                                 
                    WHERE
                       user = '".mysql_real_escape_string($row_user['ID'])."'
             
                    ");
            $res23 = mysql_fetch_array($sqle);

echo <table>
  echo <tr>
    echo "<td>".$row_user['ID']." </td><td><input type=\"image\" src=\"images/".htmlentities($row_user['receive'], ENT_QUOTES)."\" id=\"status\" name=\"status\" ></td>
  echo </tr>
echo </table>
}
include(“function.php”);
while($row\u user=mysql\u fetch\u assoc($result\u user)){
$sqle=mysql\u查询(“
从中选择计数(*)
地点2用户
哪里
user=“.mysql\u real\u escape\u字符串($row\u user['ID'])。”“
");
$res23=mysql\u fetch\u数组($sqle);
回音
回音
回显“.$row\u用户['ID']”
回音
回音
}

还有一个function.php,带有changestatus($id)函数,它更新数据库值,但我认为,这不是编写代码的正确方法。

编程时,不要只依赖javascript。我总是使用html和css创建表单,确保它工作,然后使用jQuery等添加花哨的内容。这样,您知道表单在没有javascript的情况下也可以工作(非常适合没有它的用户)

但说到你的问题:

如果您使用此功能,它应能满足您的要求:

<?php echo "<form action='?' method='post'>
<table>
<tr>
<td>".$row_user['ID']." </td>
<td><input type='hidden' name='userId' value='".$row_user['ID']."'/>
   <input type=\"image\" src=\"images/".htmlentities($row_user['receive'], ENT_QUOTES)."\" id=\"status\" name=\"status\" ></td>
  </tr>
</table></form>";

哦,好吧,这对我来说是一个不错的解决方案,因为我在js an jquery中只处于初学者状态。所以这对我来说是完美的。我尝试这种方式并让你知道。thx是一个快速的答案!这个解决方案很好而且简单。只有表单不应该从一开始就开始。每个表行中都必须有一个表单,因为有一个表单,你就可以使用它请仅获取表的最后一个id。
谢谢您的帮助!