This seems like something simple so I must be missing something, but I am having issues reducing the spacing between table rows in the output from the following:
<table align="center" width="100%" cellspacing="100">
<th width="100px;"></th>
<tbody id="ajax_res">
<?php
include 'db_connect.php';
$query = "SELECT INSERT_DATE,LINE_TEXT FROM DATA_TAB ORDER BY INSERT_DATE DESC";
$result = mysql_query($query);
while($row = mysql_fetch_array($result))
{
$insert_date = $row['INSERT_DATE'];
$line_text = $row['LINE_TEXT'];
echo "<tr height='10'><td>".$insert_date."</td>";
echo "<td align='left' width='nowrap' style='padding:0 25px 0 25px;'>".$line_text."</td></tr>";
}
mysql_close($con);
?>
</tbody>
</table>
Any ideas?
The use of cellspacing="100" is what is causing your table to bloat.
On a side note, your HTML tags should be using double quotes, not single quotes and your TH tags need to be inside TR tags. Here is what I came up with while looking for your original issue.
<style type="text/css">
table, tr, td, tbody {
margin: 0;
padding: 0;
}
table {
width: 100%;
}
td {
padding: 5px;
}
.date {
text-align: center;
}
.text {
text-align: left;
padding: 0px 25px;
}
</style>
<table>
<tr>
<th>Date</th>
<th>Text</th>
</tr>
<tbody id="ajax_res">
<?php
include 'db_connect.php';
$query = 'SELECT INSERT_DATE,LINE_TEXT FROM DATA_TAB ORDER BY INSERT_DATE DESC';
$result = mysql_query($query);
while($row = mysql_fetch_array($result)) {
$insert_date = $row['INSERT_DATE'];
$line_text = $row['LINE_TEXT'];
echo
"\t\t", '<tr>', "\n",
"\t\t\t", '<td class="date">', $insert_date, '</td>', "\n",
"\t\t\t", '<td class="text">', $line_text, '</td>', "\n",
"\t\t", '</tr>', "\n";
}
mysql_close($con);
?>
</tbody>
</table>
尝试删除或减少表的cellspacing:
<table align="center" width="100%" cellspacing="10">
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.