Javascript 更新数据库中的一行后,再次运行php行

Javascript 更新数据库中的一行后,再次运行php行,javascript,php,jquery,Javascript,Php,Jquery,如果可能,在更新数据库中的表后再次运行php行 我有一个触发jQuery.post的html按钮: btn.onclick = function(e) { $.post('inc/pstPts.php', { pts: pts }); } 在pstps.php中,我进行了查询,它成功地更新了目标行。 我在html中加载了该行,其中包含以下内容: <?php for ($i=0; $i < $q-&

如果可能,在更新数据库中的表后再次运行php行

我有一个触发jQuery.post的html按钮:

btn.onclick = function(e) {
    $.post('inc/pstPts.php',
          {
              pts: pts
          });
}
在pstps.php中,我进行了查询,它成功地更新了目标行。 我在html中加载了该行,其中包含以下内容:

<?php 
    for ($i=0; $i < $q->query_numrows(); $i++) { 
    print '<tr><td>' . $d[$i]['user_nom'] . ' ';
    print '<tr><td>' . $d[$i]['user_ape'] . ' ';
    print '<tr><td>' . $d[$i]['user_email'] . ' ';
    print '<tr><td>' . $d[$i]['user_cel'] . ' ';        }
?>
但这已经加载了旧数据


更新后,我只想运行这5行代码。

因为您的代码非常少,所以我将发布伪代码来给出一个想法

服务器端:

注意:要绑定参数以使查询不受sql注入的影响,请遵循以下示例

客户端:


完成…

标题和问题非常不同。已更改。谢谢。然后进行更新,然后再次选择,构建标记,然后用responsefyi替换该行:单引号字符串不会在其中插入变量。只需编辑它并绑定那些vars.oopsy,我做了相反的事情。@wwwanaya那么您面临的问题是什么?基本上我想做的是,加载已更新的数据。试想一下:我有一个html,它带有一个加载数据的for循环,在这个html中我有一个更新数据库中的行的按钮,我想做的是加载新数据。类似于在实时模式下查看数据库中的数据。上面所述就是这样做的。
//get the inputs from $_POST

// update the database

$update = $db->update($_POST); //simplified. just an example

if($update !== false)
{
   $entry = $db->query("SELECT * FROM foo ...... WHERE id = $_POST['id']"); //take care of sql injections.

  foreach($entry as $i)
  {
      //build up the html and echo it
  }
}
$.post({
  //url
}).done(function(data){
      $('#selector').html(data);
});