我正在构建一个网页,每个标签上都有3个标签,其中包含一个我在数据库表中提取的表格。
ID| Case| Name| Document| Date
----------------------------------------------
1 233 alex ITR 2015-1-1
2 233 alex ITR 2015-1-1
3 233 alex NULL 0000-0-0
4 234 ben COC 2015-3-3
5 234 ben VAT 2015-3-3
6 234 ben NULL 0000-0-0
在每个选项卡上都有不同的sql查询来显示表。我已经有了sql公式,我知道基本的PHP在桌面上显示它,只是不知道如何在html选项卡中加载它。这是我到目前为止的代码
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="sample.js"></script>
<link rel="stylesheet" type="text/css" href="sample.css">
<div class="tabs">
<ul class="tab-links">
<li class="active"><a href="#tab1">Tab #1</a></li>
<li><a href="#tab2">Tab #2</a></li>
<li><a href="#tab3">Tab #3</a></li>
<li><a href="#tab4">Tab #4</a></li>
</ul>
<div class="tab-content">
<div id="tab1" class="tab active">
<<?php
//conection:
$link = mysqli_connect("sssss","xxxxxxxxxxxxx","yyyyyyyyyyyyyy","xxxxxxxxxxxxxx") or die("Error " . mysqli_error($link));
//consultation:
$query = "SELECT * FROM export_workflow.COLLATERAL_MANAGEMENT
where DATEDIFF(CURDATE(),ORIGINAL_DEADLINE)>1;
" or die("Error in the consult.." . mysqli_error($link));
//execute the query.
$result = $link->query($query);
echo" <center> <table border = 3>
<tr>
<th>App Number</th>
<th>Spoc Assigned</th>
<th>Borrower Name</th>
<th>App Finish Date</th>
<th>Developer & Project</th>
<th>Collateral Address Details</th>
<th>Deferred Document</th>
<th>Deferred Type</th>
<th>Original Deadline</th>
<th>Date Completed</th>
<th>SPOC Remarks</th>
<th>File Location</th>
<th>JUW MA Remarks</th>
<th>COSU Remarks</th>
<th>SMU Notes</th>
</tr></center>";
while($row = mysqli_fetch_array($result)){
echo "<td>".$row['APP_NUMBER']."</td>";
echo "<td>".$row['SPOC_ASSIGNED']."</td>";
echo "<td>".$row['BORROWER_NAME']."</td>";
echo "<td>".$row['APP_FINISH_DATE']."</td>";
echo "<td>".$row['DEVELOPER_PROJECT']."</td>";
echo "<td>".$row['COLLATERAL_ADDRESS_DETAILS']."</td>";
echo "<td>".$row['DEFERRED_DOCUMENT']."</td>";
echo "<td>".$row['DEFERRED_TYPE']."</td>";
echo "<td>".$row['ORIGINAL_DEADLINE']."</td>";
echo "<td>".$row['DATE_COMPLETED']."</td>";
echo "<td>".$row['SPOC_REMARKS']."</td>";
echo "<td>".$row['FILED_LOCATION']."</td>";
echo "<td>".$row['JUW_MA_REMARKS']."</td>";
echo "<td>".$row['COSU_REMARKS']."</td>";
echo "<td>".$row['SMU_NOTES']."</td>";
echo "</tr>";
}
mysqli_close($link);
?>
</div>
<div id="tab2" class="tab">
<p>Tab #2 content goes here!</p>
<p>Donec pulvinar neque sed semper lacinia. Curabitur lacinia ullamcorper nibh; quis imperdiet velit eleifend ac. Donec blandit mauris eget aliquet lacinia! Donec pulvinar massa interdum risus ornare mollis. In hac habitasse platea dictumst. Ut euismod tempus hendrerit. Morbi ut adipiscing nisi. Etiam rutrum sodales gravida! Aliquam tellus orci, iaculis vel.</p>
</div>
<div id="tab3" class="tab">
<p>Tab #3 content goes here!</p>
<p>Donec pulvinar neque sed semper lacinia. Curabitur lacinia ullamcorper nibh; quis imperdiet velit eleifend ac. Donec blandit mauris eget aliquet lacinia! Donec pulvinar massa interdum ri.</p>
</div>
<div id="tab4" class="tab">
<p>Tab #4 content goes here!</p>
<p>Donec pulvinar neque sed semper lacinia. Curabitur lacinia ullamcorper nibh; quis imperdiet velit eleifend ac. Donec blandit mauris eget aliquet lacinia! Donec pulvinar massa interdum risus ornare mollis. In hac habitasse platea dictumst. Ut euismod tempus hendrerit. Morbi ut adipiscing nisi. Etiam rutrum sodales gravida! Aliquam tellus orci, iaculis vel.</p>
</div>
</div>
</div>
</body>
</html>
答案 0 :(得分:1)
您的代码中的一些修复和一些建议:
<div class="tab-content">
<div id="tab1" class="tab active">
<?php
//conection:
$link = new mysqli("xxxxxxx", "xxxxxx", "xxxxxx", "xxxxxxxxxx");
if($link->connect_errno){
printf("Connect failed: %s\n", $mysqli->connect_error);
exit();
}
//consultation:
$query = "SELECT * FROM export_workflow.COLLATERAL_MANAGEMENT where DATEDIFF(CURDATE(),ORIGINAL_DEADLINE)>1";
//execute the query.
if($result = $link->query($query)){
echo "<table border=3>\r\n";
echo "<tr>\r\n";
echo "<th>App Number</th>";
echo "<th>Spoc Assigned</th>";
echo "<th>Borrower Name</th>";
echo "<th>App Finish Date</th>";
echo "<th>Developer & Project</th>";
echo "<th>Collateral Address Details</th>";
echo "<th>Deferred Document</th>";
echo "<th>Deferred Type</th>";
echo "<th>Original Deadline</th>";
echo "<th>Date Completed</th>";
echo "<th>SPOC Remarks</th>";
echo "<th>File Location</th>";
echo "<th>JUW MA Remarks</th>";
echo "<th>COSU Remarks</th>";
echo "<th>SMU Notes</th>";
echo "</tr>\r\n";
while($row = $result->fetch_assoc()){
echo "<tr><td>".$row['APP_NUMBER']."</td>";
echo "<td>".$row['SPOC_ASSIGNED']."</td>";
echo "<td>".$row['BORROWER_NAME']."</td>";
echo "<td>".$row['APP_FINISH_DATE']."</td>";
echo "<td>".$row['DEVELOPER_PROJECT']."</td>";
echo "<td>".$row['COLLATERAL_ADDRESS_DETAILS']."</td>";
echo "<td>".$row['DEFERRED_DOCUMENT']."</td>";
echo "<td>".$row['DEFERRED_TYPE']."</td>";
echo "<td>".$row['ORIGINAL_DEADLINE']."</td>";
echo "<td>".$row['DATE_COMPLETED']."</td>";
echo "<td>".$row['SPOC_REMARKS']."</td>";
echo "<td>".$row['FILED_LOCATION']."</td>";
echo "<td>".$row['JUW_MA_REMARKS']."</td>";
echo "<td>".$row['COSU_REMARKS']."</td>";
echo "<td>".$row['SMU_NOTES']."</td>";
echo "</tr>";
}
$results->close();
echo "</table>\r\n";
} else {
printf("<p>Error: %s</p>\r\n", $mysqli->error);
}
?>
</div>
<div id="tab2" class="tab">
<p>Tab #2 content goes here!</p>
<p>
<?php
// Perform next SQL Query
if($result = $link->query("SELECT * FROM caseTickets")){
echo "<table>\r\n";
echo "<tr><th>ID</th><th>Case</th><th>Name</th><th>Document</th><th>Date</th></tr>\r\n";
while($row = $result->fetch_assoc()){
echo "<tr><td>{$row['ID']}</td><td>{$row['Case']}</td><td>{$row['Name']}</td><td>{$row['Document']}</td><td>{$row['Date']}</td></tr>\r\n";
}
echo "</table>\r\n";
$result->close();
} else {
printf("<p>Error: %s</p>\r\n", $mysqli->error);
}
?>
</p>
</div>
<div id="tab3" class="tab">
<p>Tab #3 content goes here!</p>
<p>
<?php
// Perform next SQL Query
?>
</p>
</div>
<div id="tab4" class="tab">
<p>Tab #4 content goes here!</p>
<p>
<?php
// Perform next SQL Query
?>
</p>
</div>
</div>
</div>
<?php
$link->close();
?>