vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   How to call a Profile field in a php file? (https://vborg.vbsupport.ru/showthread.php?t=78236)

neocorteqz 03-16-2005 10:49 PM

How to call a Profile field in a php file?
 
I'm trying to create a webcam script, and would like to use a hidden profile field where the member can enter his/her address to the webcam and it will automatically add to the page.

How could one accomplish this smartly, and what would be the query to select from a certain field? i know how to call from a field in a template, but don't know how to accomplish this in a php file.

thanks.

Adrian Schneider 03-16-2005 11:17 PM

Just run a query... Off the top of my head:

PHP Code:

$cache=$DB_site->query_first("SELECT fieldX FROM userfield WHERE userid=Y"); 

Typing $cache[fieldX] would display the field.

I'm not sure what mroe you want, but this should do the main part.

neocorteqz 03-16-2005 11:25 PM

Quote:

Originally Posted by TheSpecialist
Just run a query... Off the top of my head:

PHP Code:

$cache=$DB_site->query_first("SELECT fieldX FROM userfield WHERE userid=Y"); 

Typing $cache[fieldX] would display the field.

I'm not sure what mroe you want, but this should do the main part.

actually from all users that have that field filled in if it's possible. afterall I would think scanning empty rows would not cause undue stress.

So i would drop the WHERE userid=X and it would scan for all?

Ohh, and thanks. :)

Adrian Schneider 03-17-2005 12:26 AM

Pretty much, yes.

You actually need to run a while. Try this:
PHP Code:

$query $DB_site->query("SELECT fieldX FROM userfield");
while(
$array=$DB_site->fetch_array($query))
{
    
$webcamurl $array['fieldX'];
    
// Declare anything else here
    
$webcamurlbit .= "$webcamurl'<BR>';


Or a template based one:
PHP Code:

$query $DB_site->query("SELECT fieldX FROM userfield");
while(
$array=$DB_site->fetch_array($query))
{
    
$webcamurl $array['fieldX'];
    
// Declare anything else here
    
eval('$variable = "' fetch_template('template_name') . '";');


For the second one, you'd create a template and inlclude anything you want repeated inside of it (could be rows of a table (including the $webcamurl)). Then just insert $variable into your main template, and it will repeat the contents.

Edit: by the way, if your php file isn't associated with vBulletin (doesn't include global.php) you have to use mysql_query instead of $DB_site->query and mysql_fetch_array instead of DB_site->fetch_array. Also, if this is the case, you can't use templates, obviously. :)

neocorteqz 03-17-2005 02:04 AM

Quote:

Originally Posted by TheSpecialist
Pretty much, yes.

You actually need to run a while. Try this:
PHP Code:

$query $DB_site->query("SELECT fieldX FROM userfield");
while(
$array=$DB_site->fetch_array($query))
{
    
$webcamurl $array['fieldX'];
    
// Declare anything else here
    
$webcamurlbit .= "$webcamurl'<BR>';


Or a template based one:
PHP Code:

$query $DB_site->query("SELECT fieldX FROM userfield");
while(
$array=$DB_site->fetch_array($query))
{
    
$webcamurl $array['fieldX'];
    
// Declare anything else here
    
eval('$variable = "' fetch_template('template_name') . '";');


For the second one, you'd create a template and inlclude anything you want repeated inside of it (could be rows of a table (including the $webcamurl)). Then just insert $variable into your main template, and it will repeat the contents.

Edit: by the way, if your php file isn't associated with vBulletin (doesn't include global.php) you have to use mysql_query instead of $DB_site->query and mysql_fetch_array instead of DB_site->fetch_array. Also, if this is the case, you can't use templates, obviously. :)

thanks for the info. :)

Yerah it's going to include global.php. so it will work, but thanks for the info. :)

filburt1 03-17-2005 03:01 AM

If the user is logged in, just use $bbuserinfo['fieldn'] in your PHP, just as you woul d in a template.


All times are GMT. The time now is 09:13 AM.

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.01754 seconds
  • Memory Usage 1,742KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (6)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete