我正在尝试使用一个函数在我的 php 数组中显示附加信息。我正在回显显示我的类信息的表,我无法让 Jquery 在 PHP 中工作。我在 Jquery 或 PHP 方面不是最有经验的,所以我一定是完全错误的。
编辑:我知道我的 PHP 查询不安全,我最终开始转换这些查询。这是我的代码
<link rel="stylesheet" type="text/css" href="css/bigcalendar.css">
<!DOCTYPE html>
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
<title>Webbook | View Schedule</title>
<link rel='stylesheet' type='text/css' href='css/style.css' />
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">
</script>
<script type='text/javascript' src='js/jquery.ba-hashchange.min.js'></script>
<script type='text/javascript' src='js/dynamicpage.js'></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("#hidetest").toggle(1000);
});
});
</script>
</head>
<body>
<div id="page-wrap">
<header>
<?php include "navbar.php";?>
</header>
<section id="main-content">
<div id="guts">
<h2>View Schedule</h2>
<?php
//get database settings
include("dbinfo.php");
?>
<div align="center">
<?php
$sqlschedule = mysql_query("SELECT * FROM schedule WHERE student='Austin' ORDER BY `hour` ASC");
$num_rows = mysql_num_rows($sqlschedule);
//Table starting tag and header cells
while($row = mysql_fetch_array($sqlschedule)){
//Display the results in different cells
$hour = $row['hour'];
$class = $row['class'];
$teacher = $row['teacher'];
$classid = $row['classid'];
$sqlclassid = mysql_query("SELECT * FROM classes WHERE classid=$classid");
while($row2 = mysql_fetch_array($sqlclassid)){
$hour2 = $row2['hour'];
$class2 = $row2['class'];
$teacher2 = $row2['teacher'];
}
if($class == ""){
$class = $class2;
}
if($teacher == ""){
$teacher = $teacher2;
}
$sqlhourinfo = mysql_query("SELECT * FROM hours WHERE hour='$hour'");
while($row3 = mysql_fetch_array($sqlhourinfo)){
$starttime = strftime("%l:%M %P", strtotime($row3['starttime']));
$endtime = strftime("%l:%M %P", strtotime($row3['endtime']));
}
/*
$from = mysql_query("SELECT * from members WHERE username='$fromuser'");
$num_rows = mysql_num_rows($from);
//Table starting tag and header cells
while($row = mysql_fetch_array($from)){
//Display the results in different cells
$otherid = $row['id'];
$theusername = $row['username'];
}
*/
echo '<p>This is a paragraph with little content.</p>
<p style="display:none" id="hidetest">This is another small paragraph.</p>
<button>Toggle</button>
';
echo '
<table id="background-image" width="50%" border="0" cellspacing="5" cellpadding="10">
<tr>
<th width="10%" rowspan="2" class="scheduleform" scope="col">'.$hour.'</th>
<td align="left" scope="col">'.$class.'</td>
</tr>
<tr>
<td align="left">'.$teacher.'</td>
</tr>
<tr>
<td colspan="2"><p>Starts: '.$starttime.'<br>
Ends: '.$endtime.'
</p></td>
</tr>
<tr>
<td>
<a href="#" id="opener">
<img border="0" src="/webbook/images/256.png" alt="Add Assignment" width="32" height="32"></a>
</td>
<td>
<a href="#">
<img border="0" src="/webbook/images/256 (1).png" alt="Edit Assignment" width="32" height="32"></a>
</td>
</tr>
</table>
</p>
';
}
?>
</div>
</div>
</div>
</div>
</section>
</div>
<footer>
©2013 iHeff Webbook
</footer>
<?php /*
include('../footer.php');
*/ ?>
</body>
</html>
所以我想要实现的是有一个带有“添加分配”的图像的链接。我希望能够单击它,然后显示一个隐藏的表单,您可以切换它。先感谢您。