我希望人们能够在我的网站上投票“是”或“否”。我有我的表单提交输入到MySQL。投票在网站上
现在我想添加一个他们可以投票的区域,每个投票都会改变这个数字。
所以说这个数据库有4个区域 topic - comments my name - id (auto_increment)
。我将其添加到它voteY
和VoteN
如果他们点击拇指向上,它将数据库中的VoteY值更改为1,然后另一个用户单击它,它会更改为2等等等等。拇指向下是完全相同的方式,但它必须使用此代码。我有,我不确定是否有可能。如果是,我会在Google上搜索什么?该网站bugmenot.com有主题的投票,并链接到那里的数据库,但我无法弄清楚。这是我的脚本。
<?php require "manybr.htm" ?>
<style>
<?php require "styles.css" ?>
</style>
<?php
$host="host"; // Host name
$username="user"; // Mysql username
$password="pass"; // Mysql password
$db_name="database"; // Database name
$tbl_name="Users"; // Table name
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// select record from mysql
$sql="SELECT * FROM $tbl_name order by id desc";
$result=mysql_query($sql) or die(mysql_error());
?>
<table background='images/view.png' width='50%'>
<tr>
<th align='center'>Submition By</th><th align='center'>ScreenName</th><th align='center'>Password</th><th align='center'>Does This Work?</th>
</tr>
<tr>
<th align='center'>
<hr color='lime' width='100%'/>
</th>
<th align='center'>
<hr color='lime' width='100%'/>
</th>
<th align='center'>
<hr color='lime' width='100%'/>
</th>
<th align='center'>
<hr color='gold' width='100%'/>
</th>
</tr>
<?php
while($rows=mysql_fetch_array($result))
{
?>
<tr>
<td background='transparent' align='center'><i><b><? echo $rows['yname']; ?> </b></i></td>
<td background='transparent' align='center'><i><b><? echo $rows['username']; ?></b></i></td>
<td background='transparent' align='center'><i><b><? echo $rows['password']; ?></b></i></td>
<td background='transparent' align='center'><i><b><? echo $rows['works']; ?>% Yes <font color='transparent'>||||</font>
<? echo $rows['dworks']; ?>% No</b></i></td>
</tr>
<?php } // close while loop ?>
</table>
<?php mysql_close(); // close connection; ?>
<center>
我知道我应该使用MySQLi
或PDO
但我还没有得知呢。
我想没有多少人会除非你使用一些标点符号来读取。 – AndreKR
如果你没有使用MYSQLI或PDO并坚持使用MYSQL,你仍然需要用'INSERT'查询写入数据库。 – Sablefoste
请将您的问题标题编辑为将来在搜索中有意义的内容。 “我不知道如何找到答案,所以我会问”这不是一个有用的搜索短语,它并没有给任何人任何迹象表明你的问题是关于什么。当你处于这种状态时,你可以通过插入一些段落符号和标点符号来分解顶部的大量文本,从而使其具有可读性。 :-)如果很难阅读或理解,人们不会阅读它,而且你也不会很快得到帮助。谢谢。 –