|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
Transmitter Smarty Rookie
Joined: 03 Oct 2003 Posts: 5
|
Posted: Fri Oct 03, 2003 4:54 pm Post subject: getting nuts with an associative array :( |
|
|
Hi everyone!
I have big Problems by using an associative array ..
The data came from MySQL with the ADOdb engine:
[php:1:463a378e49]
$aktive_empfaenger['newsletter_section_index'][$i] = $i;
$aktive_empfaenger['newsletter_id'][$i] = $mail_empfaenger->fields[0]; // ID des Abonnenten
$aktive_empfaenger['newsletter_name'][$i] = $mail_empfaenger->fields[1]; // Name des Abonnenten
$aktive_empfaenger['newsletter_mail_adresse'][$i] = $mail_empfaenger->fields[2]; // Mailadresse des Abonnenten
$aktive_empfaenger['newsletter_status'][$i] = $mail_empfaenger->fields[3]; // Status des Abonnenten
$i++;
[/php:1:463a378e49]
I try to assign $mail_empfaenger to smarty:
[php:1:463a378e49]
$smarty->assign
(
array
(
"SECTION_INDEX" => $aktive_empfaenger['newsletter_section_index'],
"NEWSLETTER_ID" => $aktive_empfaenger['newsletter_id'],
"NEWSLETTER_NAME" => $aktive_empfaenger['newsletter_name'],
"NEWSLETTER_MAIL_ADRESSE" => $aktive_empfaenger['newsletter_mail_adresse']
)
);
[/php:1:463a378e49]
And my template file:
Code: |
<!--{section name=daten loop=$SECTION_INDEX}-->
<!--{strip}-->
<tr align="center">
<td align="left">
<!--{$SECTION_INDEX.newsletter_name}-->
</td>
<td align="left">
<!--{$SECTION_INDEX[daten].newsletter_mail_adresse}-->
</td>
<td align="right">
<input name="<!--{$SECTION_INDEX[daten].newsletter_id}-->" type="checkbox" id="name" value="1" <!--{if $$SECTION_INDEX[daten].newsletter_status == 1 }-->checked<!--{/if}-->>
</td>
</tr>
<!--{/strip}-->
<!--{/section}-->
|
And i canīt get it working, i hope you can help me with this problem.
I also tried a foreach in the template, but it dosnīt work, too.
Where is my mistake?
Thank you
Transmitter |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Fri Oct 03, 2003 5:15 pm Post subject: |
|
|
if you define your values as above, you should be able to access the elements inside the section with:
{$NEWSLETTER_ID[daten]}, {$NEWSLETTER_NAME[daten]} and
{$NEWSLETTER_MAIL_ADRESSE[daten]} |
|
Back to top |
|
Transmitter Smarty Rookie
Joined: 03 Oct 2003 Posts: 5
|
Posted: Fri Oct 03, 2003 5:40 pm Post subject: |
|
|
Thank you for your fast reply!
And for the solution to my problem: it works
But .. iīve another question: is there a better ( more performant ) way of programming something like that? |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|