Gossamer Forum
Home : Products : DBMan : Customization :

Show record if 'status' field = "active"?

Quote Reply
Show record if 'status' field = "active"?
Where could I insert code to only view a record if a given field is set 'active'? For example:

if ($rec{'status'} eq "active"){
display record;
}
Quote Reply
Re: Show record if 'status' field = "active"? In reply to
Check out the following item:

www.gossamer-threads.com/scripts/forum/resources/Forum12/HTML/000241.html

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us

[This message has been edited by Eliot (edited June 07, 1999).]

[This message has been edited by Eliot (edited June 07, 1999).]
Quote Reply
Re: Show record if 'status' field = "active"? In reply to
Thanks Elliot. This works, but ideally I don't want a user to alter the url and be able to see the other listings. All they have to so with this method is remove the &status=open and they see all records. There must be somewhere within the script that you can set certain permissions to view different status'. But where..... I suppose you could do an if statement at the beginning of html_record that exits the sub if the status is not correct but then I think that your hits count is going to be out of whack. I'll keep trying but let me know if anyone else has it figured. Should be quite simple I think....

[This message has been edited by mike1 (edited June 07, 1999).]

[This message has been edited by mike1 (edited June 07, 1999).]
Quote Reply
Re: Show record if 'status' field = "active"? In reply to
Aha I think we are getting close...

# Let's set restricted to 1 if the user can only view/mod their own and
# this isn't an admin.
($restricted = 1) if ($_[0] eq "view" and $auth_view_own and !$per_admin);
($restricted = 1) if ($_[0] eq "mod" and $auth_modify_own and !$per_admin);
($restricted = 1) if ($rec{'status'} eq "active");

Probably the $rec{status} isn't defined here so how else can we test the field?
Quote Reply
Re: Show record if 'status' field = "active"? In reply to
I tried to answer this yesterday, but I got disconnected in the midst of things. I don't know what the problem was.

What you can do, Mike, is add a line right at the beginning of sub query in db.cgi.

Just after

local (%sortby);

add

$in{'status'} = "active";

That line will only allow active records to be viewed by anyone. If you want for those with admin permissions to be able to see closed records, you can use

Code:
unless ($per_admin) {
$in{'status'} = "active";
}



------------------
JPD





Quote Reply
Re: Show record if 'status' field = "active"? In reply to
Thanks again JP! It works fine but could you tell me why it works? Are you basically just adding search terms within the query sub? If so then I understand. Now what if you wanted users to be able to view staus='active', or 'pending' but not 'sold'?
Quote Reply
Elio Please do u know to do this !!! SEE PLEASE In reply to
based on this article
www.gossamer-threads.com/scripts/forum/resources/Forum12/HTML/000241.html

do u know how....?

how do i do if the status field is in another table called table A, to get the same effect of showing only record which status = active in the table A.


/db.cgi?do=search_results&db=t_rates&phonec_status=Active

t_rates is the table B.


phonec_status=Active is a field in the table A

How do i do to shows all records that match this criteria

select * from t_rates, t_phonec
where t_phonec.phonec_status=Active

do u know how?
KevinW ANDRE
webmaster@cyberbrickell.com
Quote Reply
Re: [kevinws] Elio Please do u know to do this !!! SEE PLEASE In reply to
Are you using the SQL version of DBMan? If not, are you using the relational mod?

With DBMan you can't specify search criteria between 2 databases, that I know of. If this is the SQL version, then perhaps asking in that forum would help to get an answer, as I'm not familiar at all with that version or how it functions as far as searching, etc.

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/