tp5删除

</center>
<table id="sample-table-1" class="table table-striped table-bordered table-hover">
    <thead>
    <tr>

        <th class="center">
            <label>
                <input type="checkbox" class="ace" />
                <span class="lbl"></span>
            </label>
        </th>
        <th>商品编号</th>
        <th>商品名称</th>
        <th>商品图片</th>
        <th>所属分类</th>
        <th>水果重量</th>
        <th>水果库存</th>
        <th>已销售量</th>
        <th>产地</th>
        <th>销售价</th>
        <th>会员价</th>
        <th>是否上架</th>
        <th>是否参与活动</th>
        <th>操作</th>
    </tr>
    </thead>

    <tbody class="body">
    {foreach name='data' item='v'}
    <tr>
        <td class="center">
            <label>
                <input type="checkbox" class ='box' name="box" alt="{$v.f_id}"/>
                <span class="lbl"></span>
            </label>
        </td>


        <td>{$v.f_id}</td>
        <td>{$v.f_name}</td>
        <td><img src="<?php echo $v['f_img'];?>" alt="" width="50"></td>
        <td>{$v.t_name}</td>
        <td>{$v.f_weight}</td>
        <td>{$v.f_surplus}</td>
        <td>{$v.f_sale}</td>
        <td>{$v.f_place}</td>
        <td>{$v.m_price}</td>
        <td>{$v.v_price}</td>
        <td>
            {if condition="$v.is_show == 1"}
             上架
            {else /}
         下架
            {/if}
        </td>
        <td>
            {if condition="$v.is_hot== 1"}
             参与活动
            {else /}
         不参与活动
            {/if}
        </td>
        <td>
            <a href="{:url('index/Goods/modify')}?fid={$v.f_id}">编辑</a>
            <button class="del" alt="{$v.f_id}">删除</button>
        </td>

    </tr>
    {/foreach}



    </tbody>
</table>
<center>
<table >

<script>


        //单删
        $('.del').click(function(){
           var fid=$(this).attr('alt');
            var _this=$(this);
//            alert(fid);
            $.ajax({
                type: "GET",
                url: "index.php/index/goods/del",
                data: "fid="+fid,
                success: function(msg){
                   if(msg==1){
                       _this.parent().parent().remove();
                       alert('删除成功');

                   }else {
                       alert('删除失败');
                   }
                }
            });
        })

</script>


//单删
public function del(){
   $fid=$_GET['fid'];//获取商品id
   $res=Db::table('sg_fruits')->where("f_id= $fid")->delete();
   if($res){
      echo 1;
   }else{
      echo 2;
   }
}




  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值