Cant get data from MySQL

Hey guys,
I am tryin out the scheduler for the first time, and I can’t make it load the event-data from a MySQL Database. It would be very nice if someone could help me, I am new to this kind of scripts…

My table is called “events” with columns “id”, “start_date”, “end_date” and “text”.

HTML-Code:


<!doctype html>
<head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
    <title>Loading data from a database</title>

    <script src="module/scheduler/codebase/dhtmlxscheduler.js" type="text/javascript" charset="utf-8"></script>
    <link rel="stylesheet" href="module/scheduler/codebase/dhtmlxscheduler.css" type="text/css" title="no title" charset="utf-8">

    <style type="text/css" media="screen">
        html, body{
            margin:0px;
            padding:0px;
            height:100%;
            overflow:hidden;
        }	
    </style>

    <script type="text/javascript" charset="utf-8">
        function init() {

            scheduler.config.xml_date = "%Y-%m-%d %H:%i";
            scheduler.config.prevent_cache = true;

            scheduler.config.lightbox.sections = [
                {name: "description", height: 130, map_to: "text", type: "textarea", focus: true},
                {name: "location", height: 43, type: "textarea", map_to: "details"},
                {name: "time", height: 72, type: "time", map_to: "auto"}
            ]
            scheduler.config.first_hour = 4;
            scheduler.locale.labels.section_location = "Location";
            //scheduler.config.details_on_create=true;
            //scheduler.config.details_on_dblclick=true;



            scheduler.init('scheduler_here', new Date(2009, 10, 1), "month");
            scheduler.setLoadMode("month")
            scheduler.load("data/events.php");

            var dp = new dataProcessor("data/events.php");
            dp.init(scheduler);

        }
    </script>

</head>

<body onload="init();">
    <div id="scheduler_here" class="dhx_cal_container" style='width:100%; height:100%;'>
        <div class="dhx_cal_navline">
            <div class="dhx_cal_prev_button">&nbsp;</div>
            <div class="dhx_cal_next_button">&nbsp;</div>
            <div class="dhx_cal_today_button"></div>
            <div class="dhx_cal_date"></div>
            <div class="dhx_cal_tab" name="day_tab" style="right:204px;"></div>
            <div class="dhx_cal_tab" name="week_tab" style="right:140px;"></div>
            <div class="dhx_cal_tab" name="month_tab" style="right:76px;"></div>
        </div>
        <div class="dhx_cal_header">
        </div>
        <div class="dhx_cal_data">
        </div>		
    </div>
</body>

events.php:

require_once('../../module/scheduler/codebase/connector/scheduler_connector.php');
	
        // Mysql
	 $dbtype = "MySQL";
	 $res=mysql_connect("localhost", "root", "MyPassword");
	 mysql_select_db("MyDataBaseName");

	$scheduler = new schedulerConnector($res, $dbtype);
	$scheduler->render_table("events","event_id","start_date,end_date,details");

Any suggestions ?

Thanks in advance !

best wishes,
dokta

$scheduler->render_table(“events”,“event_id”,“start_date,end_date,details”);
You are using “details” here, but isn’t this field is named “text” in the database ?

Other code looks fine, try to load data/events.php directly in browser
Does it show valid xml output ? ( if it doesn’t show anything - check php log for errors )
Does dates in xml are in Y-m-d format ?

works now, thanks

hi,
how to get the “sections” from mysql query?
for the moment, I make “sections” as variable (var sections) and get the events data from mysql.
when I run the events_json.php directly from browser, it returns correct data, except the “id” returns something like: “id”:“1384843352x0”
in fact, I put string to the “id”
the problem, it doesn’t show the events to schedule.
it was working well when I convert the query result as variable and parse it:
scheduler.parse(aEvents, “json”)

Kindly help.

Thanks

Hi,

what do you mean under “sections”, what data does it contain ?
Sections of timeline view, sections property of an event or a collection of events in general ?

Hi Serge,
Thanks for your response.
Really sorry forgot to mention that I tried on timeline scheduler.
“sections” is the y_unit variable (as you may find it on dhtmlx example: 08_time_scale.html)
I tried to combine timeline scheduler and dhtmlx.calendar, so when the date changed on the calendar, it will reload data from MySQL (perhaps using PHP) for the requested date, and refresh the scheduler.
I couldn’t find the way to refresh the scheduler with reloading data.

Any help is definitely appreciated.
Thanks

Hi,

to reload data in scheduler call “scheduler.load(‘source.php’)”, for example in “onBeforeViewChange” or “onViewChange” event. Those events will be fired for mini calendar too.