Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/63.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 向引导模式发送变量_Php_Mysql_Variables_Twitter Bootstrap - Fatal编程技术网

Php 向引导模式发送变量

Php 向引导模式发送变量,php,mysql,variables,twitter-bootstrap,Php,Mysql,Variables,Twitter Bootstrap,以下是我的php函数: function displayrecords(){ $sql = "SELECT * FROM mytable"; $QueryResult = @mysql_query($sql) or die (mysql_error()); // more code... 此时,函数将在表中打印出返回的数据: echo "<table class='table table-striped table-bordered table-hover'>\n";

以下是我的php函数:

 function displayrecords(){
 $sql = "SELECT * FROM mytable";
 $QueryResult = @mysql_query($sql) or die (mysql_error());
 // more code...
此时,函数将在表中打印出返回的数据:

 echo "<table class='table table-striped table-bordered table-hover'>\n";
 while(($Row = mysql_fetch_assoc($QueryResult)) !== FALSE) {
您会注意到,
$sql
正在将
$id
读取为输入标记,因此,它无法在数据库中找到id,因此不会返回任何内容。我知道这是从上面的回音表中的锚定标签开始的

我需要在锚定标记中使用
$\u GET
(或
POST
),但我不知道放在哪里。我猜它应该放在
id=\\”.$Row[pk\u tId].“\”
中,但是当php已经在该id中使用时,该怎么做呢


我是一个视觉化的人,如果你能提供一个例子,我将不胜感激。

你需要一点javascript来操纵你的模式,这取决于你点击了哪个按钮。我认为这个解决方案会对你有所帮助

首先,我假设您的model中有一个表单,您将使用所选的
id
提交它。模态体应如下所示:

<div class="modal-body">
  <form action="//your/path/to/php" method="post">
    <input type="hidden" name="selected_id" id="selected_id" />
    <input type="submit" name="commit" value="Confirm your action?" />
  </form>
</div>
爪哇岛

$('.open-EditRow').click(function(){
   var selected_id = $(this).attr('data-id');
   $('#myEditModal #selected_id').val(selected_id);
   $('#myEditModal').modal('show');
});

现在,在接收post数据的modal表单中声明的php文件中,您可以
var\u dump
the
$\u post

您能提供一个var\u dump的示例以及我如何使用它吗?现在,当我单击链接时,模式窗口不再打开;echo$id;它返回null。为什么?
var\u dump($\u POST)
函数将显示
$\u POST
数组的内容。它只是用来调试和查看您通过post收到的内容。您应该将
$\u POST['selected\u id']
的值用作
$id=$\u POST['selected\u id']
;我不知道你是否会得到这个,但是如果你得到了,在表单中的模式窗口中,我添加了php标记并进行了var_dump($_POST);和$id=$\u POST['selected\u id'];然后它打印出来:数组(3){[“resgroup”]=>string(4)“test”[“restype”]=>string(0)”“[“service”]=>string(0)”}是的,你应该把你的
var\u dump
放在php文件中,这是表单的
操作
,而不是放在模式代码中。
<div class="modal-body">
  <form action="//your/path/to/php" method="post">
    <input type="hidden" name="selected_id" id="selected_id" />
    <input type="submit" name="commit" value="Confirm your action?" />
  </form>
</div>
echo "<tr><td><a class=\"open-EditRow btn btn-primary btn-mini\" data-id=\"".$Row[pk_tId]."\" title=\"Edit this row\" \">Delete/Edit</a></td>";
$('.open-EditRow').click(function(){
   var selected_id = $(this).attr('data-id');
   $('#myEditModal #selected_id').val(selected_id);
   $('#myEditModal').modal('show');
});