我有一個html文件(thumbs up/thumbs down test page),它執行兩個php文件......一個用於豎起大拇指,另一個用於豎起大拇指。多次將html插入到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);
?>
如果你給我們你的php代碼,我可以給你一個更精確的解決方案。否則,我可以告訴你我該怎麼做。 – Sanchit 2013-02-17 06:29:34
好的。有html和php文件(downvote.php基本相同)。我無法弄清楚如何不讓他們一起跑。 – 2013-02-17 06:39:18