我有一个html文件(thumbs up/thumbs down test page)执行两个php文件...一个用于竖起大拇指,一个用于竖起大拇指。
我现在需要做的是将此代码插入页面(State of Debate debate list),以便每个辩论标题可以进行排名并相应地上下移动。
我的朋友,我一直在与他合作,完成了大部分编码,包括PHP和表格。
我的问题是:有没有办法竖起大拇指,在页面上的每个辩论标题旁边竖起大拇指?到目前为止,我所取得的最好成绩是将所有竖起大拇指放在桌子上方。
//test.html
<html>
<body>
<a href="upvote.php" onClick="alert('You have given this item a thumbs up! You can change
your vote, or leave it how it is.')"; onMouseOver="return changImage()" onMouseOut=
"return changImageBack()" ><img
name="jsbutton2" src="Graphics/thumbs-up-unclicked.jpeg" width="75" height="75" border="0"
alt="javascript button"></a>
<script type="text/javascript">
function changImage()
{
document.images["jsbutton2"].src= "Graphics/thumbs-up.jpeg";
return true;
}
function changImageBack()
{
document.images["jsbutton2"].src = "Graphics/thumbs-up-unclicked.jpeg";
return true;
}
</script>
<a href="downvote.php" onClick="alert('You have given this item a thumbs down! You can change your vote, or leave it how it is.')"; onMouseOver="return changeImage()" onMouseOut= "return changeImageBack()" ><img
name="jsbutton1" src="Graphics/thumbs-down-unclicked.jpeg" width="75" height="75" border="0"
alt="javascript button"></a>
<script type="text/javascript">
function changeImage()
{
document.images["jsbutton1"].src= "Graphics/thumbs-down.jpeg";
return true;
}
function changeImageBack()
{
document.images["jsbutton1"].src = "Graphics/thumbs-down-unclicked.jpeg";
return true;
}
</script>
</body>
</html>
//upvote.php
<?php
session_start();
?>
<?php
$server = "X";
$dbusername = "X"; //database username
$dbpassword = "X"; //database password
$dbdatabase = "X"; //database name
$sqlconnect = mysql_connect($server, $dbusername, $dbpassword) or die("Couldn't connect to SQL Server on $server");
$sqldb = mysql_select_db($dbdatabase,$sqlconnect) or die("Couldn't open database $dbdatabase");
$sql="INSERT INTO Votes (UID, date, rating)
VALUES
('{$_SESSION['UID']}', CURDATE(), 1)";
if (!mysql_query($sql,$sqlconnect))
{
die('Error: ' . mysql_error());
}
mysql_close($sqlconnect);
?>
答案 0 :(得分:0)
从数据库中检索数据时,在循环浏览每个数据库记录时,写下表格的一行,当您这样做时,在循环时显示一个拇指图像。例如:
echo "<table>";
while { // loops through DB record matches...
echo "<tr><td>" . $topic_name;
if ($thumbs == 'UP') {
echo "<img src='thumbsup.jpg'>";
}
else {
echo "<img src='thumbsdown.jpg'>";
}
// Also, if you want clickable thumb up/down buttons, put them here
// and pass hidden form variables with the topic's unique record ID
// & specific voting action to a submission page.
//
// Sorta like this:
// <form>
// <input type='hidden' name='topicid' value='" . $id . ">
// <input type='hidden' name='action' value='THUMBSUP'>
// <input type='submit' value='THUMBS UP'>
// </form>
// & then repeat for thumbs down, only changing the 'action' field
echo "</td><tr>";
}
echo "</table>";
Sorta有意义???