Reputation: 11
I'm trying to create a table where I could insert lists of data one column at a time, however the way I've seen tables formatted in HTML/Bootstrap seems clunky and only allows for rows to be edited. Here is an example of what I mean:
<table>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
<tr>
<td>February</td>
<td>$80</td>
</tr>
</table>
Ideally I would just like to put all months right after one another, all savings amounts one after another, but acheive the same results that would appear in the above code. It appears there is only an option <tr>
for table rows, but not <tc>
for table columns. I want to type something like I have below, but have the same results as the code above:
<table>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tc>
<td>January</td>
<td>February</td>
</tc>
<tc>
<td>$100</td>
<td>$80</td>
</tc>
</table>
Upvotes: 0
Views: 66
Reputation:
HTML doesn't have <tc>
but this is gonna work. And you have to work with vertical table format else you can't add more data. If you add one more month how you manage it to place. This code is just for example not recommended:
<table>
<tr>
<th>Month</th>
<td>January</td>
<td>$100</td>
</tr>
<tr>
<th>Savings</th>
<td>February</td>
<td>$80</td>
</tr>
</table>
Your first code is gonna work well that's why HTML supports tr, td not tc format.
Upvotes: 0
Reputation: 321
There is no such thing as <tc>
.
You said it yourself.
Even if there's an approach to what you're trying to do here, it would make your future data for the table disorganized.
When working with a database, you should always think of displaying the records within the database in a row format, not column because you need to see if all the data associated with your identifier on the database were appearing properly. Also, all database queries work in the same format (displaying all records in a row format).
If you need to add another column in the table, your database should also add another column for each row, as well as the name for the column itself in the <th>
section.
Upvotes: 1