Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 06-21-2009, 12:03 PM
cono1717 cono1717 is offline
 
Join Date: Sep 2008
Posts: 165
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Cutom Field on Custom Page??

How do I access a users selection from a custom field on a custom page.

Currently I have tried $auinfo[field7] $userinfo[field7] which brings up nothing and $bbuserinfo[field7] which brings up my selection when I want to see their selection.

Any help?

Thanks
Reply With Quote
  #2  
Old 06-21-2009, 02:33 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Are you sure field 7 is the correct field number? What does your template look like? What is the query you are using to get this users info? Did you make sure to JOIN with the userfield table?
Reply With Quote
  #3  
Old 06-21-2009, 05:33 PM
cono1717 cono1717 is offline
 
Join Date: Sep 2008
Posts: 165
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

1) yes 7 is the correct number.

2) My template is the following.
ACTIVITY
HTML Code:
$stylevar[htmldoctype]
<html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]">
<head>
$headinclude
<title>$vboptions[bbtitle] - Activity Statistics</title>
</head>
<body$onload>
$header
$navbar
<div align="center">
<form action="activity.php" method="get">
<strong>Choose another timeframe:</strong><br />
<select name="m">$mbits</select> <select name="y">$ybits</select> <input type="submit" name="submit" value="Go" />
</form>
</div>
<br />

<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr>
	<td class="tcat" colspan="6">
		Activity Statistics for $monthliteral
	</td>
</tr>
<tbody>
	<tr>
		<td class="thead">Rank</td>
		<td class="thead">Username</td>
                <td class="thead">Current Package</td>
		<td class="thead">Posts This Month</td>
		<td class="thead">Posts Required</td>
		<td class="thead">Action Needed?</td>

	</tr>
$userbits
</tbody>
</table>
$footer

</body>
</html>
ACTIVITY_bits
HTML Code:
<tr>
		<td class="alt1">$c</td>
		<td class="alt2"><a href="member.php?$session[sessionurl]u=$auinfo[userid]">$auinfo[username]</a>
		<td class="alt1">$auinfo[field5]</td>
		<td class="alt2">$auinfo[total]</td>
                <td class="alt2">30</td>
<if condition="is_member_of($bbuserinfo, 5, 6, 7)">
<if condition="$auinfo[total] == 30">
<td class="alt1">No Action Required</td>
<else />
<td class="alt1"><font color="#FF0000"><b>Action Required</b></font></td>
</if></if>
	</tr>
3)I am not sure what you mean here so I here is the PHP file.

PHP Code:
<?php

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

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('THIS_SCRIPT''activity');

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();

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

// pre-cache templates used by all actions
$globaltemplates = array('ACTIVITY','ACTIVITY_bits''ACTIVITY_mbits''ACTIVITY_ybits''MEMBERINFO''memberinfo_profilefield');

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

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

// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################

if(empty($_REQUEST['do']))
{

    
// sanitize the variables myself
    
if(empty($_REQUEST['m']))
    {
        
$month vbdate('n');
        
$monthliteral vbdate('F');
    }
    else
    {
        
$month intval($_REQUEST['m']);
        
$monthliteral $months["$_REQUEST[m]"];
    }
    
    if(empty(
$_REQUEST['y']))
    {
        
$year vbdate('Y');
    }
    else
    {
        
$year intval($_REQUEST['y']);
    }

    
// generate months dropdown
    
$months = array(
        
=> 'January',
        
=> 'February',
        
=> 'March',
        
=> 'April',
        
=> 'May',
        
=> 'June',
        
=> 'July',
        
=> 'August',
        
=> 'September',
        
10 => 'October',
        
11 => 'November',
        
12 => 'December'
    
);
    
    foreach(
$months AS $mkey => $mval)
    {
        if(
$mkey == $month)
        {
            
$checked ' selected="selected"';
        }
        eval(
'$mbits .= "' fetch_template('ACTIVITY_mbits') . '";');
        unset(
$checked);
    }
    
    
// generate years dropdown
    
for($i intval(vbdate('Y')); $i intval(vbdate('Y')) + 4$i++)
    {
        if(
$i == $year)
        {
            
$checked2 ' selected="selected"';
        }
        eval(
'$ybits .= "' fetch_template('ACTIVITY_ybits') . '";');
        unset(
$checked2);
    }            
    
    
// important cutoff data
    
$cutoffstart gmmktime(000$month1$year);
    
$cutoffend gmmktime(000$monthvbdate('t'$cutoffstart), $year);
    
    
//echo $cutoffstart . '=' . TIMENOW;
    
    
if($cutoffstart TIMENOW)
    {
        eval(
standard_error('This date is in the future. You cannot select it. Go back and select antoher.'));    
    }
    
    
// limit our records
    
$limit 30000;    

    
// run query
    
$getusers $db->query("
        SELECT COUNT(p.postid) AS total
            ,p.userid
            ,u.username
            ,u.joindate
        FROM
            " 
TABLE_PREFIX "post AS p
        LEFT JOIN
            " 
TABLE_PREFIX "user as u
                ON
                    u.userid = p.userid            
        WHERE
            p.dateline > 
$cutoffstart
            AND
                p.dateline < 
$cutoffend
        GROUP BY
            userid
        ORDER BY
            total DESC
        LIMIT
            
$limit
    "
);
    
    
$c 0;
    while(
$auinfo $db->fetch_array($getusers))
    {
        
$c++;
        
$auinfo['joindate'] = vbdate($vbulletin->options['dateformat'], $auinfo['joindate'], true);
        eval(
'$userbits .= "' fetch_template('ACTIVITY_bits') . '";');    
    }
    
    
$navbits construct_navbits(array('' => 'Activity Statistics'));
    eval(
'$navbar = "' fetch_template('navbar') . '";');
    
    eval(
'print_output("' fetch_template('ACTIVITY') . '");');    
}

?>
4) Don't get what you mean so probably not, someone else built this system I am just revamping it, only I can't find the guy that built it (non vBulletin member btw)

Thanks in advance,

C
Reply With Quote
  #4  
Old 06-21-2009, 05:57 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You have only queried to get the userid and username. Nowhere in your query have you grabbed the fields from the userfield table. You can't use them in your template if never grabbed them in your query. You'll need to do another JOIN to the userfield in your $getusers query in order to have them available to you.
Reply With Quote
  #5  
Old 06-21-2009, 07:59 PM
cono1717 cono1717 is offline
 
Join Date: Sep 2008
Posts: 165
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I am not very familiar with mysql so could you tell me what that query would be and where I would put it please?
Reply With Quote
  #6  
Old 06-21-2009, 08:14 PM
Cryo Cryo is offline
 
Join Date: Dec 2003
Location: Buffalo, NY
Posts: 197
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If you change your SQL query to this...

PHP Code:
// run query
$getusers $db->query("
    SELECT COUNT(p.postid) AS total
        ,p.userid
        ,u.username
        ,u.joindate
        ,f.field7
    FROM
        " 
TABLE_PREFIX "post AS p,
        " 
TABLE_PREFIX "userfield AS f
    LEFT JOIN
        " 
TABLE_PREFIX "user as u
            ON
                u.userid = p.userid            
    WHERE
        p.dateline > 
$cutoffstart
        AND p.userid = f.userid
        AND    p.dateline < 
$cutoffend
    GROUP BY
        userid
    ORDER BY
        total DESC
    LIMIT
        
$limit
"
); 
It should work. The fields you list under the SELECT part of the query determines the results displayed. So if you don't specify you want a field to pull it won't be available in the results. Additionally, because userfields are stored in another table we need to add that with a reference.
Reply With Quote
  #7  
Old 06-22-2009, 08:12 AM
cono1717 cono1717 is offline
 
Join Date: Sep 2008
Posts: 165
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That gave me the following database error

Quote:
Database error in vBulletin 3.8.1:

Invalid SQL:

SELECT COUNT(p.postid) AS total
,p.userid
,u.username
,u.joindate
,f.field7
FROM
post AS p,
userfield AS f
LEFT JOIN
user as u
ON
u.userid = p.userid
WHERE
p.dateline > 1243814400
AND p.userid = f.userid
AND p.dateline < 1246320000
GROUP BY
userid
ORDER BY
total DESC
LIMIT
30000;

MySQL Error : Unknown column 'p.userid' in 'on clause'
Error Number : 1054
Request Date : Monday, June 22nd 2009 @ 09:11:30 AM
Error Date : Monday, June 22nd 2009 @ 09:11:30 AM
Script : http://www.geekstep.com/activity.php
Referrer :
IP Address : 80.47.176.108
Username : Connor
Classname : vB_Database
MySQL Version : 5.0.81-community
Reply With Quote
  #8  
Old 06-23-2009, 10:01 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Find:
Code:
AND p.userid = f.userid
Replace With:
Code:
AND p.postuserid = f.userid
Reply With Quote
  #9  
Old 06-23-2009, 03:35 PM
cono1717 cono1717 is offline
 
Join Date: Sep 2008
Posts: 165
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

New error now:-

Quote:
Database error in vBulletin 3.8.1:

Invalid SQL:

SELECT COUNT(p.postid) AS total
,p.userid
,u.username
,u.joindate
,f.field7
FROM
post AS p,
userfield AS f
LEFT JOIN
user as u
ON
u.userid = p.userid
WHERE
p.dateline > 1243814400
AND p.postuserid = f.userid
AND p.dateline < 1246320000
GROUP BY
userid
ORDER BY
total DESC
LIMIT
30000;

MySQL Error : Unknown column 'p.postuserid' in 'where clause'
Error Number : 1054
Request Date : Tuesday, June 23rd 2009 @ 04:34:56 PM
Error Date : Tuesday, June 23rd 2009 @ 04:34:56 PM
Script : http://www.geekstep.com/activity.php
Referrer :
IP Address : 80.47.2.106
Username : Connor
Classname : vB_Database
MySQL Version : 5.0.81-community
Reply With Quote
  #10  
Old 06-24-2009, 06:49 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Actually. "p.userid" should be correct. Have you set a table prefix in your config.php?
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:47 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04399 seconds
  • Memory Usage 2,334KB
  • Queries Executed 12 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (2)bbcode_html
  • (2)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete