0
這些是我的代碼。我的PHP頁面:我應該如何將我的json代碼包含在我的php文件和html文件中
$con = mysqli_connect($host, $username, $password, $db_name);
if (!$con) {
die('Could not connect: ' . mysqli_error($con));
}
mysqli_select_db($con,"ajax_demo");
$sql = "SELECT problem.id, problem.DateTimeCreated, status.status_desc, users.username FROM problem
JOIN issue ON problem.issue_id = issue.id
JOIN status ON problem.status = status.id
JOIN users ON problem.reported_account_id = users.id
where issue_id = '3'";
$result = mysqli_query($con,$sql);
echo '<table width="200" border="0" cellpadding="0" cellspacing="0">';
echo "<table>
<tr>
<th>Unique ID</th>
<th>Date</th>
<th>Status</th>
<th>Reported by</th>
</tr>";
while($row = mysqli_fetch_array($result)) {
echo "<tr>";
echo "<td>" . $row['id'] . "</td>";
echo "<td>" . $row['DateTimeCreated'] . "</td>";
echo "<td>" . $row['status_desc'] . "</td>";
echo "<td>" . $row['username'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($con);
我的html代碼:
<script>
function display(){
var xmlhttp = new XMLHttpRequest();
var url = serverURL() + "/gwifiv2.php";
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
}
}
xmlhttp.open("GET", url, true);
xmlhttp.send();
}
</script>
</head>
<body>
<div data-role="page" data-theme="a">
<div data-role="header" data-position="inline">
<a href="index.html" data-icon="home" data-theme="a"><br></a>
<h1>Issues</h1>
<a href="domain.html" data-icon="arrow-l" data-theme="a"><br></a>
</div>
<div data-role="content" data-theme="a">
<div data-role="main" class="ui-content">
<table data-role="table" data-mode="columntoggle" class="ui-responsive ui-shadow" id="myTable">
<thead>
<form>
<input type="button" value="Display" onclick="display()">
</form>
<tr>
<th>Unique ID</th>
<th data-priority="1">Date</th>
<th data-priority="2">Status</th>
<th data-priority="3">Ticket</th>
</tr>
</thead>
我無法顯示從數據庫上我的HTML代碼得到我的PHP表。如果我直接輸入我的php頁面的url,它會顯示錶格,但是當我將我的代碼插入到我的andriod設備時,表格不顯示。