PDA

View Full Version : Create a Seperate Page for Custom Profile Fields


Starscream
10-02-2004, 07:26 AM
I have searched around and have been unable to find an answer to my question. Forgive me if I missed it somewhere.

How would I go about creating a page that displays only the username and custom profile field of all the users on my site? I only want the User to show up on the list if he has that profile field filled out.

Basically, what I want to do is have a page where users can go to see all the other members profile field. For example: If I create a field for Xbox Live Gamertags and users fill it out, I want other members to see it on a seperate page called Xbox Gamertags.

Is this possible? Has this been done? Any help would be greatly appreciated.

Thanks

Starscream
10-03-2004, 05:11 PM
I know it would be similar to memberlist, I'm just not sure how to make users only show if they have that profile feild filled out.

Starscream
10-06-2004, 04:16 AM
This is what I have as far as the php file is concerned. It's wrong, but it's a start - I think. I also have made two templates which I can post if they would help.

<?php
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'GTList');

// ######################### REQUIRE BACK-END ############################
require_once('./global.php');

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// pre-cache templates used by all actions
$globaltemplates = array(
'GTLIST'
'GT_listbit
);

// pre-cache templates used by specific actions
$actiontemplates = array();

// get special phrase groups
$phrasegroups = array();

// get special data templates from the datastore
$specialtemplates = array();

################################################## ######################

$users = $DB_site->query("
SELECT user.*,usertextfield.*,userfield.*, user.userid, options,
IF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid

$GT = $DB_site->query("SELECT user.userid, user.username, usertextfield.userid, usertextfield.field5 FROM users, usertextfield WHERE user.userid == usertextfield.userid ORDER BY user.username DESC");


// pre-cache templates used by specific actions
$actiontemplates = array();

// ######################### REQUIRE BACK-END ############################
require_once('./global.php');

// ### ALL DONE! SPIT OUT THE HTML AND LET'S GET OUTA HERE... ###

while($row=mysql_fetch_object($GT))
{

$who = $row->username;
$gtname = $row->field5;

eval('$gtbit = "' . fetch_template('GT_listbit') . '";');

}

eval('print_output("' . fetch_template('GTLIST') . '");');

eval('$navbar = "' . fetch_template('navbar') . '";');


I'm pretty sure this is disorganized and somethings are incorrectly placed, but I am new to this and have very little idea of where things go.

Please help! Thanks.

edited - made some changes but not fixed

Colin F
10-06-2004, 04:25 AM
I'd advise to move this part near the top:
// pre-cache templates used by all actions
$globaltemplates = array(
'GTLIST'
'GT_listbit
);

// pre-cache templates used by specific actions
$actiontemplates = array();

// ######################### REQUIRE BACK-END ############################
require_once('./global.php');

Especially because without the global.php you won't be able to use the object $DB_site


Then, you'll also need to move this:
while($row=mysql_fetch_object($GT))
{

$who = $row->username;
$gtname = $row->field5;

eval('$gtbit = "' . fetch_template('GT_listbit') . '";');

}

eval('print_output("' . fetch_template('GTLIST') . '");');
further down, as that has to be able to use $GT, which you only define later on.

And lastly, it won't help doing two queries if they both have the same varname, as the second will overwrite the first.
You might try to just use on query.


I'll post an edited version if I have time later on, gotta go now :)

Starscream
10-06-2004, 05:58 AM
Thanks for your help. I think I am slowly beginning to understand (or, at least, I'm trying to understand).

Colin F
10-06-2004, 07:24 AM
I haven't checked the SQL syntax, but here's your code, cleaned up a bit more:

<?php
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'GTList');

// ######################### REQUIRE BACK-END ############################
require_once('./global.php');

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// pre-cache templates used by all actions
$globaltemplates = array(
'GTLIST'
'GT_listbit
);

// pre-cache templates used by specific actions
$actiontemplates = array();

// get special phrase groups
$phrasegroups = array();

// get special data templates from the datastore
$specialtemplates = array();


eval('$navbar = "' . fetch_template('navbar') . '";');
//################################################## ######################

$GT = $DB_site->query("SELECT user.userid, user.username, usertextfield.userid, usertextfield.field5 FROM users, usertextfield WHERE user.userid == usertextfield.userid ORDER BY user.username DESC");


while($row=$DB_site->fetch_array($GT))
{

$who = $row['username'];
$gtname = $row['field5'];

eval('$gtbit .= "' . fetch_template('GT_listbit') . '";');

}

eval('print_output("' . fetch_template('GTLIST') . '");');?

?>