Home · Links · Contact Us
Home arrow Forums
Home
Features
FAQ
Screen Shots
Modules
Themes
Demos
Documentation
Forums
Contact Us
Download
Purchase
Quotes

" ... I want to tell you that your thyme product is functional and valuable beyond words. I cannot imagine why any portal would be without it. It is the cornerstone of our new project ..."

" ... Thanks for such a complete project, its making my job much easier. ..."

" ... I have now deployed 4 different calendars and our users love them ... "

" ... Easy to install and use and a great look/design. ..."

" ... This has to be the easiest to use program I think I've had to deal with at all this year. ..."


  FAQFAQ    SearchSearch  RegisterRegister   Log inLog in 
Event in category query

 
Post new topic   Reply to topic     Forum Index -> General
View previous topic :: View next topic  
Author Message
PhilP
Guest





PostPosted: Fri Feb 10, 2006 4:40 pm    Post subject: Event in category query Reply with quote

Hi,

I have a PHP script which needs to ask the question 'is this event linked to this category?'

so I have an event id and need to know if this is linked to category 16 in a situation where the etype is 26.

Is there a way to do this?

Thanks
Phil
Back to top
esoft_ian



Joined: 12 Sep 2005
Posts: 5275

PostPosted: Fri Feb 10, 2006 5:09 pm    Post subject: Reply with quote

Hi Phil,

Yup, you would do a binary and. In PHP it's:

Code:
if(($event_category & 26))


If you want to do it from SQL, it's:

Code:
select * from (thyme's table prefix)Events where id = X and (etype & 26 >= 1)


Let me know if you have any problems.
Back to top
View user's profile Send private message Visit poster's website
Guest






PostPosted: Fri Feb 10, 2006 6:11 pm    Post subject: Reply with quote

hmmm... I suspect I'm being thick, but

if I set $event_category to the event's etype, and $cat_id to the category id, I then use

Code:
if(($event_category & $cat_id)) {$checked='checked';} else {$checked="";}


and then use $checked to preselect category checkboxes, all category checkboxes get selected.

Any ideas?
Back to top
esoft_ian



Joined: 12 Sep 2005
Posts: 5275

PostPosted: Fri Feb 10, 2006 6:30 pm    Post subject: Reply with quote

Hi Phil,

The folowing produces "checked is"

Code:
$event_category = 26;
$cat_id = 4;

if(($event_category & $cat_id)) {$checked='checked';} else {$checked="";}

echo("checked is $checked");


If I change $cat_id to 16, it says "checked is checked"

Maybe there's something else in the code that you're overlooking?
Back to top
View user's profile Send private message Visit poster's website
PhilP
Guest





PostPosted: Fri Feb 10, 2006 7:13 pm    Post subject: Reply with quote

Yes, entirely possible - it's been a long day.

If I do this

Code:
$event_category = 26;
$cat_id = 4;
if(($event_category & $cat_id)) {$checked='checked';} else {$checked="";}


it works.

But if I use a $event_category value which is returned from a query, where the value is 26, it doesn't work.

Driving me nuts. It may be time to go to the pub instead...
Back to top
PhilP
Guest





PostPosted: Fri Feb 10, 2006 7:23 pm    Post subject: Reply with quote

But it turns out that if I do this

Code:
$event_category = $event_category * 1;


it works.

Bizarre.
Back to top
esoft_ian



Joined: 12 Sep 2005
Posts: 5275

PostPosted: Fri Feb 10, 2006 7:38 pm    Post subject: Reply with quote

Ahh.. PHP must be think that it's a string. When you * 1, it converts it to an integer.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
© 2005 eXtrovert software unless otherwise noted. All rights reserved.
Portions © 2004 Ben Brown. All rights reserved.
Trademarks are property of their respective owners.