Filter server side processing with $_SESSION['user_id']
Filter server side processing with $_SESSION['user_id']
Hi
Can anyone point me in the direction of a straight forward example, showing how to filter the data returned from "server_processing.php". I want to limit the data returned to match the user_id to whom it belongs to. I have had a good look through this forum, however, a solution seems to evade me.
David
P.S
Because I am still in the stage of figuring out where to start, I am unable to post any code or work in process examples.
Can anyone point me in the direction of a straight forward example, showing how to filter the data returned from "server_processing.php". I want to limit the data returned to match the user_id to whom it belongs to. I have had a good look through this forum, however, a solution seems to evade me.
David
P.S
Because I am still in the stage of figuring out where to start, I am unable to post any code or work in process examples.
This discussion has been closed.
Replies
In Allan's example code look for where $sWhere is set and add it in there.
Steph
First off, thank you for your reply, I have opted to use the mysqli version of the server_process.php script. I have commented out the SELECT string and replaced with my own for now
//$sQuery = "
// SELECT SQL_CALC_FOUND_ROWS `".implode("`, `", $aQueryColumns)."`
// FROM `".$sTable."`".$sWhere.$sOrder.$sLimit;
$sQuery = "SELECT * FROM acc_customers WHERE company_id = '$comp_id'";
Only problem is that any of the associated table filters, record pageing etc no longer work as they require the variables $table,$swhere $order etc to work.
Have you any experience in replacing the SELECT string?
David
My code to change $sWhere goes after Allan's and is as follows:
[code]
if ($extraqu <> '') {
if ($sWhere == '')
$sWhere = "WHERE ".$extraqu.' ';
else
$sWhere .= ' AND '.$extraqu.' ';
}
[/code]
I set $extraqu further up if required and is the extra query I need, I presume your code would be
[code]
if ($sWhere == '')
$sWhere = "WHERE company_id = '$comp_id' ";
else
$sWhere .= " AND company_id = '$comp_id' ";
[/code]
Steph
Thank's for that, I managed to get it working with the mysqli extension.Apologies for my late reply, however I have been without broadband for the past two days.
Again
Thank you
David