vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   vbulletin 3.8 array parse problem. (https://vborg.vbsupport.ru/showthread.php?t=295425)

ayazoglu 02-24-2013 06:00 PM

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..

kh99 02-24-2013 06:15 PM

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.

ayazoglu 02-24-2013 06:30 PM

Quote:

Originally Posted by kh99 (Post 2406030)
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.

kh99 02-24-2013 06:42 PM

Quote:

Originally Posted by ayazoglu (Post 2406037)
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.

ayazoglu 02-24-2013 06:51 PM

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

kh99 02-24-2013 07:04 PM

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.

ayazoglu 02-24-2013 07:12 PM

very good :)

thanx kh99 :)

kh99 02-25-2013 11:32 AM

Quote:

Originally Posted by ayazoglu (Post 2406037)
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.


All times are GMT. The time now is 05:32 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.01179 seconds
  • Memory Usage 1,739KB
  • 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
  • (7)bbcode_code_printable
  • (4)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)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