|
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 |
stephan__ Smarty n00b
Joined: 08 Jun 2004 Posts: 4
|
Posted: Wed Jun 09, 2004 11:05 am Post subject: rangliste |
|
|
hallo,
wie ich im englischen teil des forums schon gepostet habe, suche ich ein paar tipps fuer eine rangliste.
das ergebnis sollte in etwa so aussehen:
Code: |
Place | Score | Planets | Ships | Nick | Ally
-----------------------------------------------------
1 | 1.900 | 2 | 500 | foo | none
1 | 1.000 | 2 | 400 | bar | none
|
anfangs habe ich alles mit dem {php} tag von smarty im template gehabt, aber ich denke, dass ich damit den sinn der templates verfehlt habe
hier nochmal der alte php code:
[php:1:2ed85b9fac]<?php
$rang = "1";
$db->query("SELECT * FROM user ORDER BY punkte DESC");
while($datensatz = $db->data()) {
echo("<tr><td>".$rang++."</td>");
etc.
echo("</tr>");
}
?>[/php:1:2ed85b9fac]
danke im vorraus,
mfg stephan |
|
Back to top |
|
stephan__ Smarty n00b
Joined: 08 Jun 2004 Posts: 4
|
Posted: Wed Jun 09, 2004 11:18 am Post subject: |
|
|
hm, jetzt is mir der knopf aufgegangen.
also, ich hab jetzt alles in den arrays 1-50
Code: | {$1} Array (5)
0 => 5.249.038
1 => 137
2 => 450
3 => 1
4 => KDE
{$2} Array (5)
0 => 1.666.626
1 => 62
2 => 0
3 => 1
4 => KDE |
und das muss jetzt alles noch in die tabelle. ich habs gleich mit foreach versucht, aber ich weiss nicht, was ich bei from= nehmen soll..
koennte mir jemand einen denkanstoss geben?
danke,
mfg
stephan |
|
Back to top |
|
coach Smarty Regular
Joined: 03 Jun 2004 Posts: 65
|
Posted: Mon Jun 14, 2004 9:24 pm Post subject: |
|
|
Hallo Stephan,
lies die Daten doch als assoziatives Array per mysql_fetch_assoc ein! Finde ich sowieso etwas sauberer - so spielt später die Reihenfolge der Daten keine Rolle (also an Stelle 0 steht das, an 1 dies etc., einfach nur $mein_arrray['place'])
Dann hast du z.B.:
Code: | {$1} Array (5)
"place" => 5.249.038
"score" => 137
"planets" => 450
"ships" => 1
"nick" => KDE
{$2} Array (5)
"place" => 1.666.626
"score" => 62
"planets" => 0
"ships" => 1
"nick" => KDE |
Dann geht auch ohne was zu ändern:
Code: |
{foreach name=aussen item=ein_array from=$mein_array}
{foreach key=schluessel item=wert from=$ein_array}
{$schluessel}: {$wert}<br>
{/foreach}
<hr>
{/foreach}
|
Maik |
|
Back to top |
|
Adar Smarty Regular
Joined: 27 May 2004 Posts: 58
|
Posted: Sat Jun 19, 2004 8:39 pm Post subject: |
|
|
Hab auch ein Problem mit einer Rangliste;
Will in einem Array die Ränge haben, alss hab ich diesen Array:
Array ( [0] => Array ( [0] => Neuling [rank_title] => Neuling [1] => 0 [rank_min] => 0 ) [1] => Array ( [0] => Bekannter [rank_title] => Bekannter [1] => 20 [rank_min] => 20 ) [2] => Array ( [0] => Stammgast [rank_title] => Stammgast [1] => 40 [rank_min] => 40 ) ...
und einen array, der die User für jeden Rang listet, also:
Array ( [Neuling] => Array ( [0] => S. [1] => a. [2] => c. [3] => N. [4] => j. [5] => N. ...
Aber wie gebe ich das ganze jetzt aus?
hab bisher
Code: |
{section name=idx loop=$ranks}
<tr>
<td width="35%" rowspan="2">{$ranks[idx].rank_title}</td>
<td width="65%">{$ranks[idx].rank_min}</td>
</tr>
<tr><td>
{section name=id2 loop=$rank_users.$rank_users[idx].rank_title}
{$smarty.section.id2.index}
{$rank_users.Neuling[id2]}&
{/section}
</td></tr>
{/section}
|
...aber das will nicht so, wie ich das will... |
|
Back to top |
|
Adar Smarty Regular
Joined: 27 May 2004 Posts: 58
|
Posted: Sun Jun 20, 2004 11:13 am Post subject: |
|
|
habs schon selber:
{section name=idx loop=$ranks}
<tr>
<td width="35%" rowspan="2">{$ranks[idx].rank_title}</td>
<td width="65%">{$ranks[idx].rank_min}</td>
</tr>
<tr><td>
{assign var="title" value=$ranks[idx].rank_title}
{section name=id2 loop=$rank_users.$title}
{$rank_users.$title[id2]}&
{/section}
</td></tr>
{/section} |
|
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
|