Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/87.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中为html表上的行添加删除按钮_Php_Html_Mysql - Fatal编程技术网

在php中为html表上的行添加删除按钮

在php中为html表上的行添加删除按钮,php,html,mysql,Php,Html,Mysql,我试图使它有一个删除按钮,可以按下,它删除列,你按下删除按钮。我已经做了广泛的研究,但我似乎还没有弄明白 以下是PHP和HTML的示例: <?php $username="xxx"; $password="xxx"; $database="xxx"; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $quer

我试图使它有一个删除按钮,可以按下,它删除列,你按下删除按钮。我已经做了广泛的研究,但我似乎还没有弄明白

以下是PHP和HTML的示例:

<?php


$username="xxx";
$password="xxx";
$database="xxx";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");


$query="SELECT * FROM reservation__date ORDER BY reservation_date DESC";
$result = mysql_query ($query) or die(mysql_error());

$num=mysql_numrows($result);
mysql_close();
?>
            <table width="700" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC" id="myTable" class="tablesorter">
  <thead> 
        <tr valign="bottom" bgcolor="#000000">
          <th width="128"><span class="style1b"><strong>Reservation&nbsp;ID</strong></span></th>
          <th width="829" bgcolor="#2E64FE"><span class="style1b"><strong>Reservation&nbsp;Date</strong></span></th>
          <th width="829"><span class="style1b"></span></th>
          <!--  <th width="90"><span class="style1b"><strong>Agent/client</strong></span></th>-->
          </tr>
        </thead> 
<?php

$i=0;
while ($i < $num) {

$f1=mysql_result($result,$i,"reservation_id");
$f2=mysql_result($result,$i,"reservation_date");
?>

你可以调用一个JS函数,通过它你可以传递唯一的id。在这个id和Ajax的基本使用的帮助下,你可以执行删除操作

您可以调用JS函数,通过该函数可以传递唯一id。借助该id和Ajax的基本用法,您可以执行删除操作

while ($i < $num) {

$f1=mysql_result($result,$i,"reservation_id");
$f2=mysql_result($result,$i,"reservation_date");

echo  "<a href='#' onclick ='delete($f1);'>Delete</a>";
?>
您可以使用脚本函数获取此id

<script>
function delete(id){
//Now you can delete the data related to this id form the database using Ajax
}
</script>
您可以使用脚本函数获取此id

<script>
function delete(id){
//Now you can delete the data related to this id form the database using Ajax
}
</script>

你到底想做什么?删除您同时提到的行或列?您是希望它只显示在输出表中,还是希望它也从数据库中删除?您到底想做什么?删除您同时提到的行或列?您是希望它只显示在输出表中,还是也希望将其从数据库中删除;标签的问题是什么?在何处放置回音;标签有什么问题?有主意了!好极了+好主意!好极了+1.
$username="xxx";
$password="xxx";
$database="xxx";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$query = "delete from reservation__date where reservation_id=$_GET[id]";
$rs = mysql_query ($query);
if($rs){
  header('Location: yourfile.php');
}