我有一個看起來像這樣的索引網頁上即可顯示打開數據庫字段放入頭
name----------email-----department-----extension-----cellphone Mark [email protected] I.T 8438 9393829239
有沒有辦法讓他們知道他們的部門歸入一個數據庫?是這樣的:我已經嘗試它,它要麼不顯示任何內容或犯規類的話
**I.T** name----------email-------extension-----cellphone Mark [email protected] 8438 9393829239
我的指數代碼如下:
<?php
require_once"connection.php";
$contacts = array();
$all_contacts = "select * from contacts where contact_status = '1'";
$sql_all_contacts = $conn->query($all_contacts);
$total_contacts = $sql_all_contacts->num_rows;
while ($row = mysqli_fetch_assoc($sql_all_contacts)) {
$contacts[] = $row;
}
?>
<!DOCTYPE html>
<html>
<head>
<?php include"includes/head.inc"; ?>
</head>
<body>
<div class="wrapper">
<!-- header section -->
<?php include"includes/header.inc"; ?>
<!-- content section -->
<div class="content">
<div class="floatl"><h1><?php echo $total_contacts ?> Contact(s) Total</h1></div>
<a class="floatr" href="insert_contact.php"><input class="cancel_contact_button" type="button" value="New Contact"></a>
<div class="clear"></div>
<hr class="pageTitle">
<table border ="1" style="width:100%" id="contactsTable" class="display">
<thead>
<tr align="left">
<th>Name:</th>
<th>Email:</th>
<th>Department:</th>
<th>Extension:</th>
<th>Cellphone:</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php foreach ($contacts as $contact) {?>
<tr>
<td><?php echo $contact["name"];?></td>
<td><?php echo $contact["email"]; ?></td>
<td><?php echo $contact["department"]; ?></td>
<td><?php echo $contact["extension"]; ?></td>
<td><?php echo $contact["cellphone"]; ?></td>
<td><a href="update_contact.php?id=<?php echo $contact["contact_id"]; ?>"><i class="fa fa-pencil"></i></a> | <a href="delete_contact.php?id=<?php echo $contact["contact_id"] ?>"><i class="fa fa-trash-o"></i></a></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</body>
</html>
您想要給定部門的所有聯繫人嗎? –
我希望聯繫人顯示在他們所在的部門中作爲標題。 –
與h1,h2,h3元素一樣嗎? –