Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/249.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 使用Jquery/Bootstrap删除标签标签/添加输入文本框_Php_Jquery_Mysql_Twitter Bootstrap - Fatal编程技术网

Php 使用Jquery/Bootstrap删除标签标签/添加输入文本框

Php 使用Jquery/Bootstrap删除标签标签/添加输入文本框,php,jquery,mysql,twitter-bootstrap,Php,Jquery,Mysql,Twitter Bootstrap,我在数据库中有一列,名为URL,ID为(PK),我使用的是PHP/MYSQL 我正在显示数据库中的值,现在我想使用Jquery/Ajax执行编辑(更新)操作 当我点击编辑链接时,它会被更新/取消链接所取代,该链接工作正常,我能够执行更新操作 我的要求是当我点击编辑Url数据时,我使用的标签标签应该替换为输入文本框,我应该执行更新操作 HTML代码 <div class='col-md-4'> <label class="feed_label" id="feed_lab

我在数据库中有一列,名为URL,ID为(PK),我使用的是PHP/MYSQL

我正在显示数据库中的值,现在我想使用Jquery/Ajax执行编辑(更新)操作

当我点击编辑链接时,它会被更新/取消链接所取代,该链接工作正常,我能够执行更新操作

我的要求是当我点击编辑Url数据时,我使用的标签标签应该替换为输入文本框,我应该执行更新操作
HTML代码

<div class='col-md-4'>
    <label  class="feed_label" id="feed_label" idl='<?php echo $row->id;?>'><?php echo $row->url; ?></label>

    <input name="url1" class="form-control url1 feed_text" value="<?php echo $row->id;?>" id="url1" type="text" placeholder="enter url" style="display:none;">
</div>
<div class='col-md-2'>
    <a ide='<?php echo $row->id;?>'  id="edit" class='edit' href="#" style="display:block-inline;">EDIT</a>

    <a idu='<?php echo $row->id;?>' id="update" class='update btn btn-primary btn-sm' href='#' style='display:none;'>UPDATE</a>

    <a idd='<?php echo $row->id;?>'  id="delete" class='delete' href="#" style="display:block-inline;">DELETE</a>

    <a idc='<?php echo $row->id;?>' id="cancel" class='cancel btn btn-warning btn-sm' href='#' style='display:none;'>CANCEL</a>

</div>
//Edit Starts
    if(isset($_POST['editvalue']))
    {
        $sql = "select * from deccan where id='{$_POST['id']}'";
        $row = mysql_query($sql);
        $rows = mysql_fetch_object($row);

        header("Content-type:text/x-json");
        echo json_encode($rows);
        exit();
    }
//Ends

//UPdate Starts
    if(isset($_POST['update']))
    {
        $sql = "
            update deccan 
            set 
                url='{$_POST['upurls']}'
            where id='{$_POST['id']}'
        ";
        $result = mysql_query($sql);
        if($result)
        {
            //alert('success');
            echo 'updated successfully';
        }
        else
        {
            //alert('failed');
            echo 'failed to update';
        }
    }
//Ends
PHP代码

<div class='col-md-4'>
    <label  class="feed_label" id="feed_label" idl='<?php echo $row->id;?>'><?php echo $row->url; ?></label>

    <input name="url1" class="form-control url1 feed_text" value="<?php echo $row->id;?>" id="url1" type="text" placeholder="enter url" style="display:none;">
</div>
<div class='col-md-2'>
    <a ide='<?php echo $row->id;?>'  id="edit" class='edit' href="#" style="display:block-inline;">EDIT</a>

    <a idu='<?php echo $row->id;?>' id="update" class='update btn btn-primary btn-sm' href='#' style='display:none;'>UPDATE</a>

    <a idd='<?php echo $row->id;?>'  id="delete" class='delete' href="#" style="display:block-inline;">DELETE</a>

    <a idc='<?php echo $row->id;?>' id="cancel" class='cancel btn btn-warning btn-sm' href='#' style='display:none;'>CANCEL</a>

</div>
//Edit Starts
    if(isset($_POST['editvalue']))
    {
        $sql = "select * from deccan where id='{$_POST['id']}'";
        $row = mysql_query($sql);
        $rows = mysql_fetch_object($row);

        header("Content-type:text/x-json");
        echo json_encode($rows);
        exit();
    }
//Ends

//UPdate Starts
    if(isset($_POST['update']))
    {
        $sql = "
            update deccan 
            set 
                url='{$_POST['upurls']}'
            where id='{$_POST['id']}'
        ";
        $result = mysql_query($sql);
        if($result)
        {
            //alert('success');
            echo 'updated successfully';
        }
        else
        {
            //alert('failed');
            echo 'failed to update';
        }
    }
//Ends

感谢您的帮助,谢谢

这里我为您的案例提供示例:

HTML

<div class="container">
  <label>John</label>
  <input type="button" class="edit" value="Edit"/>
  <input type="button" class="delete" value="delete"/>
</div>
<hr/>
<div class="container">
  <label>John Who</label>
  <input type="button" class="edit" value="Edit"/>
  <input type="button" class="delete" value="delete"/>
</div>

约翰

约翰谁
JS(您可以将下面的代码简化为一个处理程序)

$(文档).on('click','edit',函数(e){
var data=$(this.prev();
if(data.is('label'))data.replace为('');
});
$(文档).on('click','delete',函数(e){
var data=$(this.prev().prev();
if(data.is('input'))data.replace为(''+data.val()+'');
});

你的表单是在表格中还是在普通表单中?你能粘贴试用代码吗?@Niranjan inside div form你试过什么吗?@JitendraPurohit