Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
  #1  
Old 02-24-2013, 06:00 PM
ayazoglu ayazoglu is offline
 
Join Date: Nov 2012
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default vbulletin 3.8 array parse problem.

my array
PHP Code:
 $users = array(
    
=> array('username' => 'Adam''email' => 'adam@adam.com'),
    
=> array('username' => 'Ben''email' => 'ben@ben.com'),
    
=> array('username' => 'Chris''email' => 'chris@chris.com')
); 

my template

PHP Code:
$users[username
How do I need to use

not printing

please help me..
Reply With Quote
  #2  
Old 02-24-2013, 06:15 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You would need something like:
Code:
$users[1][username]  
$users[2][username]  


etc

Or you could use a for loop in a plug to format your names into a string, then include the string.
Reply With Quote
Благодарность от:
ayazoglu
  #3  
Old 02-24-2013, 06:30 PM
ayazoglu ayazoglu is offline
 
Join Date: Nov 2012
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
You would need something like:
Code:
$users[1][username]  
$users[2][username]  


etc

Or you could use a for loop in a plug to format your names into a string, then include the string.
my output

PHP Code:
Array[username
I want to print an array variable in bulk.
Reply With Quote
  #4  
Old 02-24-2013, 06:42 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by ayazoglu View Post
I want to print an array variable in bulk.
There's no way to do that in a vbulletin template (in vb3). You can use a plugin to create a string (I meant plugin above, not 'plug') then put the string in a template.
Reply With Quote
  #5  
Old 02-24-2013, 06:51 PM
ayazoglu ayazoglu is offline
 
Join Date: Nov 2012
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

my sql table

tablename -> programs

- id
- url
- sahip

this table while print for vbulletin

How do I make a plug-in to do this

Loop through the screen to write the data into the database
Reply With Quote
  #6  
Old 02-24-2013, 07:04 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sorry, I don't quite undertsand all that. But I'm talking about something like this:

Code:
$users = array(
    1 => array('username' => 'Adam', 'email' => 'adam@adam.com'),
    2 => array('username' => 'Ben', 'email' => 'ben@ben.com'),
    3 => array('username' => 'Chris', 'email' => 'chris@chris.com')
);  

foreach ($users as $user)
{
   $userbits .= '<TR><TD>' . $user[username] . '</TD><TD>' . $user[email] . '</TD></TR>';
}

Then in the template:

Code:
<TABLE>
$userbits
</TABLE>

You could also use a template for each user instead of coding in the html, like:

Code:
foreach ($users as $user)
{
   eval('$userbits .= "' . fetch_template('my_userbit') . '";');
}

Then you'd need a new my_userbit template something like:
Code:
<TR><TD>$user[username]</TD><TD>$user[email]</TD>

It's exactly the same except that the html is in a template.
Reply With Quote
  #7  
Old 02-24-2013, 07:12 PM
ayazoglu ayazoglu is offline
 
Join Date: Nov 2012
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

very good

thanx kh99
Reply With Quote
  #8  
Old 02-25-2013, 11:32 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by ayazoglu View Post
my output

PHP Code:
Array[username
I want to print an array variable in bulk.

BTW, I just realized that the reason you saw "ARRAY" when you tried to follow my suggestion is because it needed curly braces around them, like:

Code:
{$users[1][username]}
{$users[2][username]}

Sorry about that.
Reply With Quote
Reply

Thread Tools
Display Modes

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 08:09 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.09002 seconds
  • Memory Usage 2,235KB
  • Queries Executed 11 (?)
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
  • (7)bbcode_code
  • (4)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (1)post_thanks_box_bit
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)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
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete