Load perticular User data in to Grid.

Hi,
I’m using mygrid.load("tasksCategory.php"); to load data from database to Grid.

Now I want to load data related only for one user from database. It means after a user login he can see only his data. I want to use php sessions. How can I use them with dhtnlx Grid? :unamused:

Can any one help me?

Hi, I guess I can help you. This is more of a general PHP/mySQL question you have.

In my application I use one (general) DB-user for all DB accesss. I instanciate like this:

if(!isset($db)) {
		$db = new mysqli($dbhost, $dbuser, $dbpass, $database);
		if ($db->connect_errno) {
			echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
		}
	}

$db is then the DB-connect object I use to connect with the grid connector in my data processor, see this thread for this logic:
viewtopic.php?f=2&t=28967 (second post)

If you want to change the DB user before the SQL gets rendered, you would have to make a new DB connect each time with a different user (above). The simple alternative would be to add a user column to the tables to display, and filter the data depending on the user logged in. PHP/mySQL applications rarely switch db users. Hope that helps!

Andreas