PDA

View Full Version : vbulletin 3.8 array parse problem.


ayazoglu
02-24-2013, 06:00 PM
my array

$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')
);


my template

$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:

$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
You would need something like:

$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

Array[username]

I want to print an array variable in bulk.

kh99
02-24-2013, 06:42 PM
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:

$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:

<TABLE>
$userbits
</TABLE>


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

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



Then you'd need a new my_userbit template something like:
<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
my output

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:

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



Sorry about that.