在我的div
中,我通過PHP協議顯示數據庫中的數據,但是,當我切換到另一個div
並返回到顯示數據庫的div
時,我不再看到數據,它只是一張空白桌子。所以我想我應該在我的javascript中添加重載功能,是嗎?幫我擺脫這種請使用onclick函數刷新div?
這裏是我的代碼
<div id="container1">
<table width="313" border="1">
<tr>
<td width="103" height="62"><div align="center">Latitude</div></td>
<td width="194" class="style5"> <div id="lat" align="center" class="style6">
<?php
const DB_HOST1 = 'localhost';
const DB_USER1 = 'root';
const DB_PASS1 = '';
const DB_NAME1 = 'gmap';
$mysqli1 = new mysqli(DB_HOST1, DB_USER1,DB_PASS1 ,DB_NAME1);
if ($mysqli1->connect_errno) {
echo "<p>MySQL error no {$mysqli1->connect_errno} : {$mysqli1->connect_error}</p>";
exit();
}
$query1 = "SELECT * FROM gmaptracker1 ORDER BY id DESC LIMIT 1";
$result1 = $mysqli1->query($query1);
if (!$result1) {
echo "Invalid query: {$mysqli1->query($query1)}:{$mysqli1->query($query1)}";
}
while ($row1 = @mysqli_fetch_assoc($result1)){echo $row1['lat'] . ',N '; ?>
</div></td>
</tr>
<tr>
<td height="60"><div align="center">Longtitude</div></td>
<td> <div align="center" class="style6">
<?php echo $row1['lng'] . ',E ';} ?></div></td>
</tr>
</table>
</div>
<div id="container2">Container #2<p>Whole bunch of text 2</div>
</div>
這裏是我的javascript
function showDiv(idInfo) {
var sel = document.getElementById('block_left_panel2').getElementsByTagName('div');
for (var i=0; i<sel.length; i++) { sel[i].style.display = 'none'; }
document.getElementById('container'+idInfo).style.display = 'block';
return false;
}
謝謝,它的工作:) – JackABC 2014-09-24 02:56:44
yo're welcome pal – 2014-09-24 03:12:56