Forum



18:07

27/04/2011

Hi experts,
I just start unsing jqGrid and I have a problem. I have a grid which is loading json data and my problem is that when i select add and submit the data nothing really happens.
I believe that I have not programmed correctly the edit_subsriber.php page. I really need your help because I am stacked for 2 days now.
Here is the page which displayes the grid:
<?php
include 'connect.php';// create values for reporttypes
$rt_array = '';$sql_rt = "SELECT * FROM reporttype WHERE activated = '1' ORDER BY name ASC";
$res_rt = mysql_query($sql_rt) or die ("Cannot create report type array.");
while ($row = mysql_fetch_array($res_rt)){
$rt_array .= $row['reporttypeid'].':'.$row['name'].';';
}
$rt_len = strlen($rt_array);
$rt_array = substr($rt_array,0,$rt_len-1);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CGM DataCS - Subscribers</title><link type="text/css" href="css/ui-lightness/jquery-ui-1.8.11.custom.css" rel="stylesheet" />
<link rel="stylesheet" type="text/css" media="screen" href="css/ui.jqgrid.css" />
<script src="js/jquery-1.5.2.min.js" type="text/javascript"></script>
<script src="js/i18n/grid.locale-en.js" type="text/javascript"></script>
<script src="js/jquery.jqGrid.min.js" type="text/javascript"></script><script>
$(document).ready(function() {
jQuery("#list2").jqGrid({
url:'data.php?q=subscriber',
datatype: "json",
colNames: ['Subscriber ID','Name', 'Report Type', 'Active'],
colModel: [
{name:'subscriberID',index:'subscriberID', width:20, align:"center", editable:false},
{name:'name',index:'name', editable:true, edittype:'text', editoptions:{size:60}},
{name:'rname',index:'rname', width:20, align:'center',editable:true, edittype:'select', editoptions:{size:60, value:"<?php echo $rt_array; ?>"} },
{name:'rstatus',index:'rstatus', width:20, align:'center', formater:'checkbox', editable:true, edittype:'checkbox', editoptions:{value:"1:0"}}
],
rowNum:25,
rowList:[25,50,100],
pager:'#pager2',
sortname:'subscriberID',
viewrecords: true,
sortorder: "desc",
caption: "Subscribers",
editurl: "edit_subscriber.php",
width:990,
height:450
});jQuery("#list2").jqGrid('navGrid','#pager2',{edit:true, add:true, del:false},
{
modal:true,
recreateForm: true,
editCaption: "Edit subscriber",
saveData: "Data has been changed! Save changes?",
bYes: "Yes",
bNo: "No",
bExit: "Cancel",
resize:false,
checkOnSubmit:true,
width: 400
},
{
modal:true,
recreateForm: true,
addCaption: "Add subscriber",
saveData: "Data has been changed! Save changes?",
bYes: "Yes",
bNo: "No",
bExit: "Cancel",
resize:false,
checkOnSubmit:true,
width: 400
}
);
});
</script>
</head>
<body><table id="list2"></table>
<div id="pager2"></div></body>
</html>
And this is what I have enter in edit_subscriber.php which should insert the new record in the database:
<?php
$name = $_POST['name'];
$reporttypeid = $_POST['rname'];
$activated = '';$sql = "INSERT INTO subscriber (name,reporttypeid,activated) VALUES ('$name,'$reporttypeid','$activated') ";
$result = mysql_query($sql) or die ("SQL error: " . mysql_error());
?>
Most Users Ever Online: 715
Currently Online:
72 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66