0

我有一个执行两个 php 文件的 html 文件(竖起大拇指/竖起大拇指的测试页)...一个用于竖起大拇指,一个用于竖起大拇指。

我现在需要做的是将此代码插入页面(辩论状态辩论列表),以便可以对每个辩论标题进行排名并相应地上下移动。

和我一起工作的朋友已经完成了大部分编码工作,包括 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);
?>
4

1 回答 1

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>";

有点道理???

于 2013-02-17T06:29:32.643 回答