Thanks for the quick relpy Alexandra,
Unfortunatly your suggestion of using resetDataProcessor hasānt worked, the debugger notes that the information is being updated and inserted as shown below:
row 1341562669890 marked [inserted,valid]
row 1341562684474 marked [inserted,valid]
row 1341562684801 marked [inserted,valid]
but nothing is showing in the db
my code is as follows:
studentDetailsDP = new dataProcessor ("resources/lib/cons/studentAdmin/studentDetails_formConfig.php");
// create an array to store the form structure
studentFormData = [
{type: "fieldset", name:"studentData", label:"Student Details",className:"formContainer",width: 1200, list:[
{type:"input", name:"Student_No",label:"Student SUN:",maxLength:9,inputWidth:70,offsetLeft:0,offsetTop:10},
{type:"input", name:"Address_Line_1", label:"Addr Line 1:",maxLength:255,inputWidth:150,offsetLeft:0,offsetTop:10},
{type:"input", name:"Post_Code", label:"Post Code:",maxLength:9,inputWidth:70, offsetLeft: 0,offsetTop:10},
{type:"input", name:"Work_Phone_No", label:"Work Phone No.:",maxLength:255,inputWidth:130,offsetLeft:0,offsetTop:10},
{type:"newcolumn"},
// coloun 2
{type:"input", name:"Forename", label:"Forname:",maxLength:255,inputWidth:150,offsetLeft:0,offsetTop:10},
{type:"input", name:"Address_Line_2", label:"Addr Line 2:",maxLength:255,inputWidth:150,offsetLeft:0,offsetTop:10},
{type:"input", name:"Personal_Email", label:"Personal Email:",maxLength:255,inputWidth:150,offsetLeft:0,offsetTop:10},
{type:"input", name:"Home_Phone_No", label:"Home Phone No.:",maxLength:255,inputWidth:130,offsetLeft:0,offsetTop:10},
{type:"newcolumn"},
// column 3
{type:"input", name:"Surname", label:"Surname:",maxLength:255,inputWidth:150,offsetLeft:0,offsetTop:10},
{type:"input", name:"Address_Line_3", label:"Addr Line 3:",maxLength:255,inputWidth:150,offsetLeft:0,offsetTop:10},
{type:"input", name:"Email", label:" Email:",maxLength:255,inputWidth:150,offsetLeft:0,offsetTop:10},
{type:"input", name:"Mobile_Phone_No", label:"Mobile Phone No.:",maxLength:255,inputWidth:150,offsetLeft:0,offsetTop:10},
{type:"newcolumn"},
// coloumn 4
{type:"newcolumn"},
{type:"select", name:"Mode_ID", label:"Mode ID:",
connector: "resources/lib/cons/studentAdmin/modeID_selConn.php" ,offsetLeft:0,offsetTop:10},
{type:"input", name:"Address_Line_4", label:"Addr Line 4:",maxLength:255,offsetLeft:0,offsetTop:10 },
{type:"select", name:"Route_ID", label:"Route ID:",connector:"resources/lib/cons/studentAdmin/routeID_selConn.php",position: "absolute",inputTop:12,inputLeft:260,labelLeft:180,labelTop:12}
//,{type:"input",name:"Placement_ID",label:"Placement ID",maxLength:9,position: "absolute",inputTop: 50,inputLeft: 330,labelLeft: 250, labelTop:50}
]}
];
// create a new form object place it within the div named grid container and
// specify the formData array as its structure.
studentDetailsForm = new dhtmlXForm("studentFormContainer",studentFormData);
//studentDetailsForm.attachEvent("onChange",function(){
// studentForm.save();
//});
// create a data processor to allow database updating via the form
//and intiate the dataprocessors connection to the form
studentDetailsDP.init(studentDetailsForm);
// load the php file required to connect to the db
studentDetailsForm.load("resources/lib/cons/studentAdmin/studentDetails_formConfig.php?id="+1);
studentFormNavData = [{type: "fieldset", name:"studentControls", label:"Controls",className:"formControls",width: 1180, list:[
{type: "fieldset", name:"navControls", label:"Navigation",width: 500, list:[
{type:"button", name:"first",value:"|<"},
{type:"newcolumn"},
{type:"button",name:"previous",value:"<<"},
{type:"newcolumn"},
{type:"button",name:"next",value: ">>"},
{type:"newcolumn"},
{type: "button",name: "last",value:">|"}
]},
{type:"newcolumn"},
{type: "fieldset", name:"opsControls", label:"Add / Delete record",offsetLeft:105,offsetTop:0,width: 500, list:[
{type:"button", name:"add_btn",value:"Add +"},
{type:"newcolumn"},
{type:"button",name:"delete_btn",value:"Delete -",command:"delete"},
{type:"newcolumn"},
{type:"button",name:"update_btn",value:"Commit",command:"insert"},
{type:"newcolumn"},
{type:"button",name:"cancel_btn",value:"Cancel"}
]}
]}];
studentNavForm = new dhtmlXForm("studentFormControls", studentFormNavData);
studentNavForm.attachEvent ("onButtonClick",function clickHandler(id,value){
if (id == "add_btn"){
studentDetailsForm.clear();
// clear the data from the screen
studentNavForm.hideItem("add_btn");
studentNavForm.hideItem("delete_btn");
// hide the delete and add buttons
studentNavForm.showItem("update_btn");
studentNavForm.showItem("cancel_btn");
// show the update and cancel buttons
}
if (id == "delete_btn"){
studentDetailsForm.resetDataProcessor("deleted");
studentDataForm.save();
}
if (id == "update_btn"){
studentNavForm.showItem("add_btn");
studentNavForm.showItem("delete_btn");
studentNavForm.hideItem("update_btn");
studentNavForm.hideItem("cancel_btn");
studentDataForm.save();
}
if (id == "cancel_btn") {
studentNavForm.showItem("add_btn");
studentNavForm.showItem("delete_btn");
studentNavForm.hideItem("update_btn");
studentNavForm.hideItem("cancel_btn");
studentDetailsForm.reset();
}
});
studentNavForm.hideItem("update_btn");
studentNavForm.hideItem("cancel_btn");
}
and for my connector
<?php
session_start();
if (!(($_SESSION['Authorised'] == true) && ($_SESSION['User_Level']) >= 1 )) {
header("Location:index.php");
}
define('CONFIG_PATH', $_SERVER['DOCUMENT_ROOT'] . '/resources');
require_once (CONFIG_PATH . '/config.php');
require_once (CODEBASE_PATH . '/connector/form_connector.php');
$host = $dbConfig ['dbSettings']['mysql']['host'];
$dbName = $dbConfig ['dbSettings']['mysql']['dbname'];
$userName = $dbConfig ['dbSettings']['mysql']['username'];
$pwd = $dbConfig ['dbSettings']['mysql']['password'];
// get the db settings for each paramter an store each in a variable
$conn = mysql_connect($host, $userName, $pwd);
mysql_select_db($dbName);
// create a new connection to the db using variables from config file
$form_conn = new FormConnector($conn);
// intilize the form connector
if (isset ($_SESSION['ID'])) {
$id = $_SESSION['ID'];
}
else {
echo "The following problem occoured while attempting student details operation: No id passed in SESSION variable";
}
$form_conn->sql->attach("update","UPDATE student SET
Student_No = {Student_No},
Surname = '{Surname}',
Forename = '{Forename}',
Email = '{Email}',
Personal_Email = '{Personal_Email}',
Home_Phone_No = '{Home_Phone_No}',
Work_Phone_No = '{Work_Phone_No}',
Mobile_Phone_No = '{Mobile_Phone_No}',
Address_Line_1 = '{Address_Line_1}',
Address_Line_2 = '{Address_Line_2}',
Address_Line_3 = '{Address_Line_3}',
Address_Line_4 = '{Address_Line_4}',
Post_Code = '{Post_Code},
Mode_ID = '{Mode_ID}',
Route_ID = '{Route_ID}'
WHERE Student_No = $id ");
$form_conn->sql->attach("Insert","INSERT into student
(Student_No,Surname,Forename,Email,Personal_Email
Home_Phone_No,Work_Phone_No,Mobile_Phone_No,Address_Line_1
Address_Line_2,Address_Line_3,Address_Line_4,Post_Code,
Mode_ID,Route_ID)
VALUES {Student_No},'{Forename}','{Surname},
'{Email}','{Personal_Email}','{Home_Phone_No}',
'{Work_Phone_No}','{Mobile_Phone_No}','{Address_Line_1}',
'{Address_Line_2}','{Address_Line_3}','{Address_Line_4}',
'{Post_Code}','{Mode_ID}','{Route_ID}'");
$form_conn->sql->attach("Delete","DELETE * FROM student
WHERE Student_No = $id");
$form_conn->render_table("student","Student_No","Student_No,Surname,Forename,Email,
Personal_Email,Home_Phone_No,Work_Phone_No,Mobile_Phone_No,Address_Line_1,
Address_Line_2,Address_Line_3,Address_Line_4,Post_Code,Mode_ID,Route_ID");
?>
However from what you have said and what I have read its looking like form may not be the best tool for the job, what my boss/client wants is basically to be able to do the following:
- view information about each recored one at a time
- Have standard first,previous,next and last record buttons to navigate.(a function that is from
what I have read not a standard feature of Form )
- Be able to update,add or delete using buttons to manipulate records
Could you possibly suggest which of your tools would be best suited to these goals as form just does not seem to do what I need (btw your Grid framework has been great to use good work on that ).
Thanks in advance.