0
我有一個HTML表我從數據庫建立:PHP函數調用弄亂表
<tr onclick="DoNav('<?php echo $result_videos[$i]["video_url"]; ?>');">
<td>
<?php echo $result_videos[$i]["camera_name"]; ?>
</td>
<td>
Timezone: <?php echo queryTimezone(); ?> <br>
Video Size: <?php echo $result_videos[$i]["video_size"]; ?> bytes <br>
Video Length: <?php echo strTime($result_videos[$i]["video_length"]); ?>
</td>
<td>
<form name="myform" action="<?php echo htmlentities($_SERVER['REQUEST_URI']); ?>" method="POST">
<input type="submit" name="delete_video" value="Delete" title="Delete this video" onClick="return confirm('Are you sure you want to delete?')"/>
<input type="hidden" name="video_url" value="<?php echo $result_videos[$i]["video_url"]; ?>" />
</form>
</td>
</tr>
問題是這樣的功能:
function queryTimezone()
{
$query = "SELECT timezone FROM #__camcloud_users WHERE user_id=".$user->id;
$db->setQuery($query);
$timezone = $db->loadResult();
return $timezone;
}
它攪亂表了。我似乎沒有得到任何PHP錯誤,並切斷了「時區:」部分的表格,並將其引至頁面的右上角。基本上我稱之爲功能queryTimezone
。如果我改變把它放在html表格中它工作正常:
<tr onclick="DoNav('<?php echo $result_videos[$i]["video_url"]; ?>');">
<td>
<?php echo $result_videos[$i]["camera_name"]; ?>
</td>
<td>
Timezone: <?php
$query = "SELECT timezone FROM #__camcloud_users WHERE user_id=".$user->id;
$db->setQuery($query);
$timezone = $db->loadResult();
echo $timezone;
?> <br>
Video Size: <?php echo $result_videos[$i]["video_size"]; ?> bytes <br>
Video Length: <?php echo strTime($result_videos[$i]["video_length"]); ?>
</td>
<td>
<form name="myform" action="<?php echo htmlentities($_SERVER['REQUEST_URI']); ?>" method="POST">
<input type="submit" name="delete_video" value="Delete" title="Delete this video" onClick="return confirm('Are you sure you want to delete?')"/>
<input type="hidden" name="video_url" value="<?php echo $result_videos[$i]["video_url"]; ?>" />
</form>
</td>
</tr>
這工作正常。我是如何稱呼功能的?
ack,謝謝。我錯誤地認爲,因爲我有'$ user =&JFactory :: getUser();'和'$ db =&JFactory :: getDBO();'全局設置它可以工作......感嘆,我有更多要學習。 – Tom 2012-01-01 21:47:54