Table does not want to be vertical

0

I wanted to know what I was doing wrong, because I created a table in the template taking information from an api. He wanted to sort himself vertically rather than horizontally.

<!Doctepyhtml><html><head><title>TestedeRequests</title><metacharset="UTF-8">
    </head>
    <body>
        <table border="1">
            <tr>
                <th bgcolor="red">Pilotos</th>
            </tr>
            <tr>
                {% for i in range(200) %}
                    {% if "IFATC" in data[i]['DisplayName'] %}
                        <td align= middle width=100>{{data[i]['DisplayName']}}</td>
                    {% endif %}
                {% endfor %}
            </tr>
        </table>
    </body>
    
asked by anonymous 29.04.2018 / 00:25

2 answers

0

For each row of the table you must also have a table trolle of your own:

{% for i in range(200) %}
    {% if "IFATC" in data[i]['DisplayName'] %}
    <tr>
        <td align=middle width=100>{{data[i]['DisplayName']}}</td>
    </tr>
    {% endif %}
{% endfor %}

That is, put the TR within the loop so they can also be repeated.

One tip, avoid using direct formatting attributes in HTML tags and formatting them directly using CSS, maintaining code and layout changes will be much simpler.

    
29.04.2018 / 00:50
-1

It's very simple, my friend. The code in the structure below will generate a horizontal table. Each new TR code block will generate a row with cells.

<tr>
       <td></td>
             ...
         <td></td>
</tr>

In the following code, we will have each new TR block containing a single cell, it will generate a vertical table.

<tr>
       <td></td>
</tr>
      ...
<tr>
       <td></td>
</tr>

But the vertical table can have more than one cell as well. So, as the friend said above, depending on how you do the loop, the result may vary.

    
29.04.2018 / 21:40