This topic is locked

details - user only see own data

12/19/2007 6:35:51 AM
PHPRunner General questions
G
garethp authorDevClub member

Hi
I have 3 tables

order_header (orderno, account, dateraised)

order_details (record, orderno, part, qty)

user (username, password, account)
order_header is the master to order_details linked on orderno
Order_header is restricted so the user can only see and edit their own data (based on user.account) - this lists all the orders for this account - perfect!
However, how do I restict the details view to only show the order_details for the assigned account. There is no 'account' in the order_details table to enable me to restict in the normal way.
I need it so when the user clicks the details tab all the order_details entreis for all the orders of the assigned account (based on the link back to order_header.account)are shown.
CAN ANYONE HELP - Many thanks

J
Jane 12/19/2007

Hi,
you can do it using List page: Before SQL query event.

Here is a sample:

global $conn;

$where = "";

$str = "select orderno from order_header where account=".$_SESSION["_order_header_OwnerID"];

$rs = db_query($str,$conn);

while ($data = db_fetch_array($rs))

$where.=$data["orderno"].",";

$where = "orderno in (".substr($where,0,-1).")";

$strWhereClause = whereAdd($strWhereClause,$where);

G
garethp authorDevClub member 12/19/2007

Jane
Thanks for your but I am struggling to make the event work and get the following message and just cant work it out.

Technical information

Error type 256

Error description Unknown column 'asd1' in 'where clause'

URL www.**.co.uk/trial/order_details_list.php?

Error file e:\domains\i\****.co.uk\user\htdocs\trial\include\dbconnection.php

Error line 26

SQL query select `record`, `orderno`, `part` From `order_details`


Can you help any futher? Many many thanks

J
Jane 12/20/2007

Hi,
this code works on my test box.

Please post your application on the Demo Account and post a URL to your pages here or send it to [email=support@xlinesoft.com]support@xlinesoft.com[/email] along with instructions on reproducing this error.

I'll find what's wrong with your project inspecting it at Demo account site.

G
garethp authorDevClub member 12/21/2007

Jane
I have sent you an email to support
Many thanks

J
Jane 12/24/2007

answered in your personal email.