deal 用来传值的php

1.

<?php



require_once '../model/nba.class.php';
$nba = new model_nba();

$id = isset($_POST['id']) ? $_POST['id'] : '';
$city = isset($_POST['city']) ? $_POST['city'] : '';      仅仅是要取的变量
$username = isset($_POST['username']) ? $_POST['username'] : '';       仅仅是要取的变量


if($id) {//edit                   if($id)==if(!empty($id))
    $rows = $nba->update($id,$city,$username);
} else {
    $rows = $nba->add($city,$username);
}
if ($rows) {
    $return = array('code'=>200,'msg'=>'ok');     200为默认值
    echo json_encode($return);
} else {
    $return = array('code'=>300,'msg'=>'error');
    echo json_encode($return);

}

仅仅是有   增加  修改  没有删除






2.

<?php
/**
 * Created by JetBrains PhpStorm.
 * User: bbu
 * Date: 15/4/26
 * Time: AM10:33
 * To change this template use File | Settings | File Templates.
 */
require_once "../model/cba.class.php";
$cba = new model_cba();
$id = isset($_REQUEST['id'])?$_REQUEST['id']:'';     $_REQUEST  不区分get和post  但是效率不怎么好
$city = isset($_POST['city'])?$_POST['city']:'';
$username = isset($_POST['username'])?$_POST['username']:'';
$action = isset($_GET['action'])?$_GET['action']:'';
//if(!empty($id))     $id不为空
if(empty($id))        $id为空
{
    $rows = $cba->add($city,$username);
}elseif($id!='' && $action == 'delete')
{
    $rows = $cba->delete($id);
    header("location:easy/grid.php");
    exit;
    //$rows = $cba->update($id,$city,$username);
}else
{
    $rows = $cba->update($id,$city,$username);
}
if(!empty($rows))
{
    $return = array('code'=>200,'msg'=>'ok');
    echo json_encode($return);
}else{
    $return = array('code'=>300,'msg'=>'no');
    echo json_encode($return);
}

增加   修改   删除 在一个页面


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值