Reputation: 175
I'm using div's en css code, to get some values out of a mysql database.
It works fine. But if the value in the database is longer than 1 row, the table with div's doesn't look nice.
This is the code I'm using:
$result = mysql_query("SELECT * FROM boxen ");
while ($row = mysql_fetch_assoc($result))
{
echo '<div class="a naam">';
echo '<a href="boxen.php?boxid=' . $row['ID'] . '">' . $row['naam'] . '</a>';
echo '</div>';
echo '<div class="a datum">';
echo $row['datum'];
echo '</div>';
echo '<div class="a land">';
echo $row['land'];
echo '</div>';
echo '<div class="a naam">';
echo $row['starter'];
echo '</div>';
}
The css code adjusts the color, and the width. Short: how do I fix the height?
P.s. I have searched on stackoverflow, but found nothing that can help me, maybe I'm using the wrong keywords?
EDIT:
<div class="inhoud">
<h2>Inhoud van de box: </h2><br />
<div class="header naam">
Naam product
</div>
<div class="header omschrijving">
Omschrijving
</div>
<div class="header aantal">
Aantal
</div>
<div class="header datum">
Datum toegevoegd
</div>
<div class="header naam">
Naam toeveoger
</div>
<div class="header datum">
Datum verwijderd
</div>
<div class="header naamVerwijderaar">
Naam verwijdereraar
</div>
<div class="header icon">
</div>
<div class="header icon">
</div>
<div class="header icon">
SAMPLE SAMPLE SAMPLE SAMPLE SAMPLE
</div>
This is the header, but it has the same problem. The last column will have 2 rows, and if I add a another line, it gets very cluttered.
And the css code:
/* Algemeen voor header*/
.header {
background-color:#4DA0FF;
float:left;
margin-left:4px;
margin-bottom:4px;
color:white;
}
/* END HEADER*/
/* ALGEMEEN OVERIZCHT*/
/* naam */
.naam{
width:200px;
height:auto;
}
/* naam die het product er uit heeft gehaald*/
.naamVerwijderaar{
width:210px;
height:auto;
}
/* datum */
.datum{
width:150px;
height:auto;
}
/* omschrijinvg */
.omschrijving{
width:200px;
height:auto;
}
.aantal {
width:80px;
height:auto;
}
/* land */
.land{
width:150px;
height:auto;
}
inhoud{
width:1305px;
}
I don't need all the css code for this example!
Upvotes: 2
Views: 1580
Reputation: 174957
You want a table for this sort of things.
Tables are not all evil, when used for the correct type of data (tabular data, i.e. the kind of data best fit in a table), tables are perfectly acceptable.
Sample code:
<style type="text/css">
th {
background-color: rgb(77, 160, 255);
margin-left: 4px;
margin-bottom: 4px;
color: rgb(255, 255, 255);
}
table caption {
font-size: 2em;
font-weight: bold;
}
</style>
<table>
<caption>Inoud van de box:</caption>
<thead>
<tr>
<th>Naam product</th>
<th>Omschrijving</th>
<th>Antal</th>
<th>Datum toegevoegd</th>
<th>Naam toevegoer</th>
<th>Datum verwijderd</th>
<th>Naam verwijderd</th>
<th> </th>
<th> </th>
<th>SAMPLE SAMPLE SAMPLE SAMPLE</th>
</tr>
</thead>
</table>
Upvotes: 1