我发现当我的php脚本生成页面时,我拒绝运行的Jquery脚本。 我希望看到一双不同的眼睛来查看我的代码。
<?php
.
. DB log in and verification done here
.
.
<html><head><link href="css/stylesheet.css" type="text/css" rel="stylesheet" />
<style>body { background-image: url(../riders/'.$riderno.'/rider_picture.jpg);background-repeat: no-repeat;background-attachment: fixed;top: 10%;background-position: center;}
</style><script type="text/javascript" src="js/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="js/jquery-ui.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$(".dialog").dialog({
autoOpen: false,
});
$(".session").click(function () {
var src = $(this).data("href");
var title = $(this).data("id");
alert("Clicked - " + src);
var $dialog = $("<div></div>")
.html("<iframe style="border: 1px; " src="'+ src + '" width="100%" height="100%"></iframe>")
.dialog({
autoOpen: false,
modal: true,
height: 625,
width: $(window).width() - 20,
height: $(window).height() - 20,
title: title
});
$dialog.dialog("open");
});
});
</script></head>
<body><div class="RiderInfo">
<?php
echo "<div class='Week'>";
$total_duration = date("H:i:s", strtotime("0:0:0"));
$total_distance = 0;
$total_tss = 0;
$total_hrtss = 0;
$avg_if = 0;
$avg_hrif = 0;
$sessions = 0;
$sql = "SELECT * FROM `RiderLog` WHERE `RiderNo` = $riderno AND `RideDate` >= '$startdate' AND `RideDate` < '$enddate' ORDER by RideDate ASC";
$result = $mysqli->query($sql) or die($mysqli->error.__LINE__);
$record=0;
if($result->num_rows > 0) {
$thisdate = $startdate;
$row = $result->fetch_assoc();
do {
echo "<div class='date'><div class='day'><strong>".date("D", strtotime($thisdate))."</strong></div>";
while ($thisdate == date("Y-m-d", strtotime($row['RideDate']))) {
$sessions++;
?><button data-id='#dialog<?php echo $record?>' class='session' data-href='fitanalysis.php?rider=<?php echo $riderno ?>&file=<?php echo $row['FIT_file']?>'><div class='duration'><?php echo $row['Duration']?></div><div class='distance'><?php echo $row['Distance'] ?>km</div>
<?php $total_duration = date("H:i:s",strtotime($total_duration)+(strtotime($row['Duration'])-strtotime("00:00:00")));
$total_distance += $row['Distance'];
?></button><?php
$row = $result->fetch_assoc();
$record++;
}
$thisdate = date("Y-m-d",strtotime($thisdate.'+ 1 day'));
echo "</div>";
} while ($thisdate <= $enddate);
echo "<div class='WeekSummary'><strong>Week Summary</strong><br>Duration : ".date("H:i:s", strtotime($total_duration))."<br>Distance : $total_distance km<br>TSS : $total_tss<br>Average IF : ".$avg_if/$sessions."</div>";
echo "</form>";
} else {
clear up and finish html page.
答案 0 :(得分:1)
首先,有一件事情,这可能不适合你。你应该用一个双引号替换那个领先的双引号。
.html("<iframe style="border: 1px; " src="'+
其次,这真的让我很恼火
var $dialog = $("<div></div>")
是这个javascript还是PHP?使用$
获取javascript变量是不必要的,只会使代码更难阅读。
这一切都在顶部
<?php
.
. DB log in and verification done here
.
.
<html><head><link href="css/stylesheet.css" type="text/css" rel="stylesheet" />
<style>body { background-image: url(../riders/'.$riderno.'/rider_picture.jpg);background-repeat: no-repeat;background-attachment: fixed;top: 10%;background-position: center;}
</style><script type="text/javascript" src="js/jquery-1.11.3.min.js"></script>
然后你有
<?php
但永远不要关闭第一个?那里一团糟。