only using ajax/php/javascipt/mysql to make a Scheduler

hi all,
There is a problem if i must only using those methods and without asp,xml,
How can i load and edit events?This problem I research for few days :frowning:

I using Stupid way to load events ,here is my code :
Mysql Structure: actNo|actDate|startTime|endTime|actName|actPlace|userNo

function init() { scheduler.locale.labels.timeline_tab = "Timeline" scheduler.locale.labels.section_UserNo="User No."; scheduler.locale.labels.section_actNo="Action No"; scheduler.locale.labels.section_actName="Action Name"; scheduler.locale.labels.section_actPlace="Location"; scheduler.locale.labels.section_holName="holName"; scheduler.locale.labels.section_holDate="holDate"; scheduler.locale.date.prototype="" scheduler.locale.labels.date="%Y-%m-%d %H:%i%s"; scheduler.config.details_on_create=true; scheduler.config.details_on_dblclick=true; scheduler.config.xml_date="%Y-%m-%d %H:%i"; scheduler.init('scheduler_here',null,"week"); //=============== //Configuration //=============== scheduler.createTimelineView({ name: "timeline", x_unit: "minute", x_date: "%H:%i", x_step: 30, x_size: 24, x_start: 16, x_length: 48, y_unit: sections, y_property: "section_id", render:"bar" }); var sections=[ {key:1, label:"1"}, {key:2, label:"2"}, {key:3, label:"3"}, {key:4, label:"4"} ]; //=============== //Data loading //=============== scheduler.config.lightbox.sections=[ {name:"actNo", height:21, map_to:"actNo", type:"template" }, {name:"actPlace", height:130, map_to:"actPlace", type:"textarea" , focus:true}, {name:"actName", height:21, map_to:"actName", type:"textarea" , focus:true}, {name:"UserNo", height:23, type:"select", options:sections, map_to:"section_id" }, {name:"time", height:72, type:"time", map_to:"auto"} ] <?php $arrayRows=mysql_query("select * from schedule;"); while($arrayScheduleRows=mysql_fetch_array($arrayRows)){ $ScheduleRows_actNo=$arrayScheduleRows['actNo']; $ScheduleRows_actDate=$arrayScheduleRows['actDate']; $ScheduleRows_startTime=$arrayScheduleRows['startTime']; $ScheduleRows_endTime=$arrayScheduleRows['endTime']; $ScheduleRows_actName=$arrayScheduleRows['actName']; $ScheduleRows_actPlace=$arrayScheduleRows['actPlace']; $ScheduleRows_userNo=$arrayScheduleRows['userNo']; ?> var arrayScheduleRows_actPlace='<?php echo $ScheduleRows_actPlace;?>'; var arrayScheduleRows_actNo=<?php echo $ScheduleRows_actNo;?>; var arrayScheduleRows_actName='<?php echo $ScheduleRows_actName;?>'; var arrayScheduleRows_Start_date = '<?php echo $ScheduleRows_startTime;;?>'; var arrayScheduleRows_end_date = '<?php echo $ScheduleRows_endTime;?>'; scheduler.parse([ {actNo:arrayScheduleRows_actNo, actName:arrayScheduleRows_actName, actPlace:arrayScheduleRows_actPlace, start_date:arrayScheduleRows_Start_date, end_date:arrayScheduleRows_end_date}, ],"json"); <?php }?>//=====loop parse [b]Fail AddEvent[/b] scheduler.attachEvent("onEventSave", function(actNo,actName,actPlace,start_date,end_date){ <?php mysql_query("insert into schedule (actNo,actDate,startTime,endTime,actName,actPlace,userNo) values ( '6', '2012-04-04', 'start_date', <==== error if i change it to [b]' ". start_date." ',[/b] 'end_date', 'asd', 'asd', '1')"); ?> this._empty_lightbox(),this.hide_lightbox() }); } if there have other way to make it , please tell me :'(

Check

scheduler\samples\01_initialization_loading\05_loading_mysql.html

It uses ajax/php/mysql and no any other technology.

[code]scheduler.attachEvent(ā€œonEventSaveā€, function(actNo,actName,actPlace,start_date,end_date){

<?php mysql_query("insert into schedule (actNo,actDate,startTime,endTime,actName,actPlace,userNo) values ( '6',[/code] This will not work for sure, you need to have something like [code]scheduler.attachEvent("onEventSave", function(id){ var ev = scheduler.getEvent(id); var url = "save.php?date="+ev.start_date; ulr+= "&end="+ev.end_date; ... dhtmlxAjax.get(url); });[/code] and in save.php you can place the php code for data saving.

thanks a lot for your help , but what should i change if my tableā€™s Structure is look like that?
Mysql Structure: actNo|actDate(date)|startTime(datetime)|endTime(datetime)|actName|actPlace|userNo
Since my lecturer said ,so i cant change this structure.

<?php include ('Connections/scheduler_connector.php'); include ('Connections/connectdb.php'); $res=mysql_connect($server, $user, $pass); mysql_select_db($db_name); $scheduler = new schedulerConnector($res); //$scheduler->enable_log("log.txt",true); $scheduler->render_table("events","actNo","actDate,startTime,endTime,actName,actPlace,userNo");<==is that right? ?>

also,in the scheduler_connector.php .Is there anything I must change if I only use this structure

i m success for load ,edit and delete event without add .
there is my way:

scheduler.attachEvent(ā€œonBeforeEventDeleteā€,Del);
scheduler.attachEvent(ā€œonEventChangedā€, function(event_id,event_object){
alert("onEventChanged: "+event_id);
Edit(event_id,event_object);
});
Failing of add event :cry:
scheduler.attachEvent(ā€œonEventAddedā€, function(event_id,event_object){
alert("onEventAdded: "+event_id);
Add(event_id,event_object,function(old_id,new_id){
scheduler.changeEventId(old_id, new_id);
});
});

moreover ,how to auto generated unique actNo in add event

scheduler.attachEvent("onEventAdded", function(event_id,event_object){ scheduler.getEvent(event_id).actNo = scheduler.uid(); ...

Beware that result value is not globally unique ( it is a very small possibility, but still two users can generate the same uid )

hi Stanislav , thanks a lots of your help :smiley:
actually,i have more problem here. :cry:

here is my problem:

if i want to let a sql like :
ā€œselect * form Scheduler where userNo = ā€˜$_Session[userNo]ā€™ā€
to be render_table like:

$conn = mysql_connect("localhost", "root","") or die("can not connect!");
mysql_select_db("projectdb",$conn) or die("cant find database");

$scheduler = new schedulerConnector($conn);

$scheduler->render_table("schedule","actNo","startTime,endTime,actName,actDate,actPlace,userNo,actNo");

what should i change on render_table() function?? Thank you :cry:

You can use render_sql

$scheduler->render_sql("select * form scheduler where userNo = '".$_Session[userNo]."'","actNo","startTime,endTime,actName,actDate,actPlace,userNo,actNo");