PHP列样式

时间:2016-12-28 07:17:27

标签: php css html-table

我需要我的表将提交包含在三列中,然后新行开始包含三列,等等。所以提交1,第一列,提交2,第二列,提交3列。然后一个新行和流程再次开始。 (下面的HTML示例代码)

每次我尝试使用我的php代码时,我的页面都会显示为空白,因此我在某处遗漏了某些内容。

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 

$sql = "SELECT id, name, website, url, email, date, description FROM basic";
$result = $conn->query($sql);

if ($result->num_rows>0){
    <tr> 
    while ($row=$result->fetch_assoc()) {
        echo "<table><tr><th><b>Company:</b> " . $row["name"]. "</th></tr><tr><td>     
        <b>URL:</b> <a href='".$row["url"]."'>".$row["url"]."</a></td></tr><tr><td> 
        <b>Email:</b> " . $row["email"]. "</td></tr><tr><td><b>Launch Date:</b> " .    
        $row["date"]. "</td></tr><tr><td><b>Announcement:</b> " .   
$row["description"]. "</td>
        </tr>";
    }
    echo "</table>";
} else {
    echo "0 results";
}

$conn->close();
?>

示例:这就是我想让它看起来像。

<style>
table, td, th {    
    border: 10px solid #ffffff;
    text-align: left;
}

table {
    border-collapse: initial;
    width: 100%;
}

td {
    padding: 15px;
    width: 25%;
    line-height: 2;
}

th {
    background-color: grey;
    color: white;
    padding: 5px;
    width: 25%; 
}
</style>

<body>
    <table class="ex1">
      <tr>
        <th>Company</th>
        <th>Company</th>
        <th>Company</th>
      </tr>
      <tr>
        <td>
            <b>URL:</b><br>
            <b>Location:</b><br>
            <b>Inductry:</b><br>
            <b>Start Date:</b><br>
            <b>Announcement:</b><br> 
            <br>
        </td>
        <td>
            <b>URL:</b><br>
            <b>Location:</b><br>
            <b>Inductry:</b><br>
            <b>Start Date:</b><br>
            <b>Announcement:</b><br> 
            <br>
        </td>
        <td>
            <b>URL:</b><br>
            <b>Location:</b><br>
            <b>Inductry:</b><br>
            <b>Start Date:</b><br>
            <b>Announcement:</b><br> 
            <br>
        </td>
    </table>

1 个答案:

答案 0 :(得分:0)

您的PHP代码未以适当的格式生成HTML。请尝试以下:

class LeaveDetailsAdmin(admin.ModelAdmin):
    list_display = ['start_date', 'end_date']

admin.site.register(Leave_Details, LeaveDetailsAdmin)