php - can't insert SQL updates -
i'm using jeasy-ui populate data grid. had working earlier today, decided move files around didn't work , rolled changes.
unfortunately populates tables , allows me delete rows saving , inserting seems nothing. worst part know it's simple i've been @ 4 hours , it's time ask i'm not seeing.
edit
was missing comma after 'date' => $date on save_user.php. knew simple. help.
html:
<!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta name="keywords" content="jquery,ui,easy,easyui,web"> <meta name="description" content=""> <title>scheduler</title> <link rel="stylesheet" type="text/css" href="css/black/easyui.css"> <link rel="stylesheet" type="text/css" href="css/icon.css"> <script type="text/javascript" src="js/jquery-1.9.1.js"></script> <script type="text/javascript" src="js/jquery-ui.js"></script> <script type="text/javascript" src="js/jquery.easyui.min.js"></script> <script type="text/javascript" src="js/jquery.datagrid.js"></script> <script type="text/javascript"> //create datafields $(function(){ $('#dg').edatagrid({ url: 'get_users.php', saveurl: 'save_user.php', updateurl: 'update_user.php', destroyurl: 'destroy_user.php' }); }); </script> </head> <body> <table id="dg" title="edit teams" style="width:700px;height:250px" toolbar="#toolbar" pagination="true" idfield="id" rownumbers="true" fitcolumns="true" singleselect="true"> <thead> <tr> <th field="date" width="50" editor="{type:'validatebox',options:{required:true}}">date</th> <th field="starttime" width="50" editor="{type:'validatebox',options:{required:true}}">time start</th> <th field="endtime" width="50" editor="{type:'validatebox',options:{required:true}}">time finish</th> <th field="team1" width="50" editor="{type:'validatebox',options:{required:true}}">team 1</th> <th field="team2" width="50" editor="{type:'validatebox',options:{required:true}}">team 2</th> </tr> </thead> </table> <div id="toolbar"> <a href="#" class="easyui-linkbutton" iconcls="icon-add" plain="true" onclick="javascript:$('#dg').edatagrid('addrow')">new</a> <a href="#" class="easyui-linkbutton" iconcls="icon-remove" plain="true" onclick="javascript:$('#dg').edatagrid('destroyrow')">destroy</a> <a href="#" class="easyui-linkbutton" iconcls="icon-save" plain="true" onclick="javascript:$('#dg').edatagrid('saverow')">save</a> <a href="#" class="easyui-linkbutton" iconcls="icon-undo" plain="true" onclick="javascript:$('#dg').edatagrid('cancelrow')">cancel</a> </div>
get_users.php (works)
<?php include 'conn.php'; $rs = mysql_query('select * schedule'); $result = array(); while($row = mysql_fetch_object($rs)){ array_push($result, $row); } echo json_encode($result); ?>
destroy_user.php
<?php $id = intval($_request['id']); include 'conn.php'; $sql = "delete schedule id=$id"; @mysql_query($sql); echo json_encode(array('success'=>true)); ?>
save_user.php
<?php $date = $_request['date']; $starttime = $_request['starttime']; $endtime = $_request['endtime']; $team1 = $_request['team1']; $team2 = $_request['team2']; require 'conn.php'; $sql = "insert schedule(date,starttime,endtime,team1,team2) values('$date','$starttime','$endtime','$team1','$team2')"; mysql_query($sql); echo json_encode(array( 'id' => mysql_insert_id(), 'date' => $date 'starttime' => $starttime, 'endtime' => $endtime, 'team1' => $team1, 'team2' => $team2 )); ?>
update_user.php
$id = intval($_request['id']); $date = $_request['date']; $starttime = $_request['starttime']; $endtime = $_request['endtime']; $team1 = $_request['team1']; $team2 = $_request['team2']; include 'conn.php'; $sql = "update schedule set date='$date',starttime='$starttime',endtime='$endtime',team1='$team1',team2='$team2' id=$id"; mysql_query($sql); echo json_encode(array( 'id' => $id, 'date' => $date, 'starttime' => $starttime, 'endtime' => $endtime, 'team1' => $team1 'team2' => $team2 ));
you used $_request
how pass data id,date
,... php files. not familiar jeasy-ui
, guess need define columns
in jquery code introduce data passed php files.
Comments
Post a Comment