[英]Print an array in Twig
I Have a table with this columns: 我有一个带有此列的表:
login ,couleur1,parties,gagnees
I would like to print an array exactly like this one: 我想打印一个像这样的数组:
In Silex I get all data in an array 在Silex中,我将所有数据存储在一个数组中
$app->get('/userlist', function(Application $app) {
$recup= $app['db']->executeQuery('SELECT * FROM users');
$results = $recup->fetchAll();
return $app['twig']->render('example.twig', array('users' => $results));
});
$app->run();
[enter image description here][2]?>
In Twig I tried to align them, but I can't get it like in the photo. 在Twig中,我尝试将它们对齐,但无法像照片中那样。
{% for row in users %}
<ul style="list-style: none;">
<li style="float:left; margin-right:30px" >{{ row.login }}</li>
<li style="float:left; margin-right:30px">{{row.parties}}</li>
<li style="float:left; margin-right:30px">{{row.couleur1}}</li>
<li style="float:both">{{row.couleur2}}</li>
</ul>
{% endfor %}
I would make that without separating CSS and Twig. 我不会分离CSS和Twig就可以做到这一点。
It will be something like this: 将会是这样的:
<table>
<tr>
<td>Joueur</td>
<td>Parties</td>
<td>Gagness</td>
<td>Colueur Preferee</td>
</tr>
{% for row in users %}
<tr>
<td>{{ row.login }}</td>
<td>{{row.parties}}</td>
<td>{{row.couleur1}}</td>
<td>{{row.couleur2}}</td>
</tr>
{% endfor %}
</table>
and apply some CSS for colors and looks. 并为颜色和外观应用一些CSS。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.