vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Pulling data out from customfields (https://vborg.vbsupport.ru/showthread.php?t=125277)

MikaK 08-29-2006 11:58 PM

Pulling data out from customfields
 
I'm planning to show 1 event by memebrs at their public profile.

This should be the query:
PHP Code:

$query "SELECT `eventid` , `userid` , `title` , `customfields` , `dateline_from`  
FROM `" 
TABLE_PREFIX "event`
WHERE userid = '
$userinfo[userid]
ORDER BY `dateline_from` DESC
LIMIT 1"


In my case the customfields contains data regarding event type and location
like in the following example: a:2:{i:1;s:4:"Club";i:2;s:8:"Helsinki";}

What would be the best php code snippet for getting "Club" and "Helsinki" in displayed the final output?

Thanks for any insight.
-Mika

Corsec 08-30-2006 02:20 AM

That is the data you want. It is an array (as seen by the "a" at the start I think) with 2 objects (denoted by the 2 at the start I believe, Im not entirely sure the inner workings of serializing data).

You can do this:

$customArray = unserialize($row["customfields"]);

array(2) {
[1]=>
string(4) "Club"
[2]=>
string(8) "Helsinki"
}

MikaK 08-30-2006 05:15 AM

Quote:

Originally Posted by Corsec
array(2) {
[1]=>
string(4) "Club"
[2]=>
string(8) "Helsinki"
}

Thanks, man! Glad to hear I'm getting there - even if by small steps:D Now... I still wonder how to formulate string (4) "Club" and string(8) "Helsinki" so it appears dynamically in the final output?
Quote:

array(2) {
[1]=>
$bbinfo['calendarfield1']
[2]=>
$bbinfo['calendarfield2']
}
perhaps?


This is the code outlining also the problematic, still missing variables
PHP Code:

$limit_page1 '1';    // Enter the number of maximum events you want to have displayed

$get_events DB_site->query ("SELECT `eventid` , `userid` , `title` , `customfields` , `dateline_from`  
FROM `" 
TABLE_PREFIX "event`
WHERE userid = '
$userinfo[userid]
ORDER BY `dateline_from` DESC
LIMIT 
$limit_page1");  

while(
$events $DB_site->fetch_array($get_events))
    {
        
exec_switch_bg();
        
$events['date'] = vbdate($vboptions['dateformat'],$events['dateline_from']);
        
// THE PROBLEM
        // how to formulate the customfields based variables ?
        // Below should be pulling clendar customfield id 1
        
$events['type'] = ' ';
        
// Below should be pulling clendar customfield id 2
        
$events['location'] = ' ';
        eval(
'$usersevents .= "' fetch_template('memberinfo_usersevents') . '";');
    } 

Now my problem only seems to be how to implement the above offered snippet into $events['type'] = ' '; and $events['location'] = ' ';

Once again... Thank's for any insight.

-Mika

MikaK 09-09-2006 02:25 PM

case solved and closed.


All times are GMT. The time now is 08:16 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.00993 seconds
  • Memory Usage 1,732KB
  • 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
  • (2)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)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