<!-- blah == 1 question....

Discussion forum for MOD Writers regarding MOD Development.
Locked
vortexhlp
Registered User
Posts: 195
Joined: Fri Jan 09, 2009 7:51 pm

<!-- blah == 1 question....

Post by vortexhlp »

I am trying to get something from a database if it's value is either 1 or 0 but for some reason it's not working.

Inside memberlist.php I have added the new variable inside

Code: Select all

$sql = $db->sql_build_query('SELECT', array(
			'SELECT'	=> 'u.user_id, u.group_id as default_group, u.username, u.username_clean, u.user_colour, u.user_rank, u.user_posts, u.user_allow_pm, [b]u.user_hpk[/b].........
(around line 181)

Defined it

Code: Select all

'USER_HPK'		=> get_user_hpk($data['user_hpk'], true),
and in my memberlist_view.php file I have:

Code: Select all

<!-- IF USER_HPK == 0 --> insert whatever here<!-- ELSE -->some stuff if it's turned on here<!-- ENDIF -->
and of course it's in the database in the user table. So, I'm not exactly sure why this doesn't work, it always shows whatever is in for value 0 but not value 1. i have even done with values all the way up to 5 (even in the conditional statements) but it didn't quite work. Should I be using == 0 or something else? Was it my programming that failed in memberlist.php? I'm confused :(

Edit: The end result I want to be able to check if a number is exactly something.

ie: <!-- USERNAME == S_USERNAME and USER_HPK == 0 -->do this<!-- ELSE -->do that<!-- ENDIF -->
updown
Registered User
Posts: 542
Joined: Sat Jan 05, 2008 6:53 am

Re: <!-- blah == 1 question....

Post by updown »

In general, your coding seems to be correct. I see two possible sources of mistakes here:

1.) The value of the variable depends on your function get_user_hpk() - check this first.

2.) Is the template-var USER_HPK a BLOCK-var? Then you need to add the blockvar to the variable in the template file, e.g. <!-- IF memberrow.USER_HPK == 0 -->
User avatar
Brf
Support Team Member
Support Team Member
Posts: 52169
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: <!-- blah == 1 question....

Post by Brf »

That is the select for the "The Team" page. The one for viewprofile is further down the page around line 400 or so:

Code: Select all

		// Get user...
		$sql = 'SELECT *
			FROM ' . USERS_TABLE . '
and it is already retrieving all of the user fields.
vortexhlp
Registered User
Posts: 195
Joined: Fri Jan 09, 2009 7:51 pm

Re: <!-- blah == 1 question....

Post by vortexhlp »

Brf wrote:That is the select for the "The Team" page. The one for viewprofile is further down the page around line 400 or so:

Code: Select all

		// Get user...
		$sql = 'SELECT *
			FROM ' . USERS_TABLE . '
and it is already retrieving all of the user fields.
Thank you! You were correct, I wasn't placing the info in the right place. I also modified the code slightly so it worked better but overall your keen eye saved my patience :) It turned out I needed to place the info around line 1160 since it is for viewing someone's profile.
Locked

Return to “[3.0.x] MOD Writers Discussion”