Insert $_SESSION variable in mysql


#1

Hi, I use the scheduler and everything work great to insert into my database via events.php file. The question I have is how can i insert automatically the $SESSION into the table sessions and in the field user_id. See below what I already have…
tks
Seby

<?php session_start(); include ('../../../codebase/connector/scheduler_connector.php'); include ('../../common/config.php'); $res=mysql_connect($server, $user, $pass); mysql_select_db($db_name); $scheduler = new schedulerConnector($res); /*$list = new OptionsConnector($res); $list->render_table("types","typeid","typeid(value),name(label)");*/ //-------------Sub Type dropdown .......................... $OtherDropdown = new OptionsConnector($res); $OtherDropdown->render_table("session_type","session_type","id(value),session_type(label)"); $scheduler->set_options("session_type",$OtherDropdown); //------------- Eof Sub Type dropdown .......................... $clients = new OptionsConnector($res); $clients->render_table("clients","full_name","id(value),full_name(label)"); $scheduler->set_options("clients",$clients); //$scheduler->enable_log("log.txt",true); //$scheduler->enable_log("log.txt",true); //$scheduler = new schedulerConnector($res); //$scheduler->render_table("events","event_id","start_date,end_date,event_name,details,types,clients"); if ($scheduler->is_select_mode()){ // ' code for loading data $SQL = "SELECT * from sessions WHERE user_id='".$_SESSION['user_id']."' "; $scheduler->render_sql($SQL,"id","start_date,end_date,session_name,session_name,session_notes,session_type,session_location,type,client_id", "", ""); } else { // code for other operations - i.e. update/insert/delete $scheduler->render_table("sessions","id","start_date,end_date,session_name,session_notes,session_type,session_location,type,client_id"); } ?>

#2

You can add extra values by adding the next code before render_table

function doprocessing($action){ $action->set_value("user_id", $_SESSION['user_id']); } $scheduler->event->attach("beforeProcessing", doprocessing); $scheduler->render_table(...


#3

Tks Stanislav… it worked…
Have a nice day!
Seby