我已经发布了这个问题 2 次都没有工作我重新编写了脚本,现在我遇到了更多问题
这是我在第一页上的代码:
<?php
$host="XXXX"; // Host name
$username="XXXX"; // Mysql username
$password="XXXX"; // Mysql password
$db_name="XXXX"; // Database name
$tbl_name="XXXX"; // 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);
?>
<table background='images/view.png' width='50%'>
<tr>
<th align='center'>Post #</th><th align='center'>Submition By</th><th align='center'>ScreenName</th><th align='center'>Password</th><th align='center'>Does This Work?</th><th align='center'>Vote</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='lime' width='100%'/>
</th>
<th align='center'>
<hr color='gold' 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['id']; ?> </b></i></td>
<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 background='transpatent' align='center'><i><b><a href='works.php?id=<? echo $rows['id']; ?>'><img src='images/ThumbsUp.png' height='30' width='30'> </a> <a href='dworks.php?id=<? echo $rows['id']; ?>'><img src='images/ThumbsDown.png' height='30' width='30'></a>
</td>
</tr>
<?php
// close while loop
}
?>
<?php
// close connection;
mysql_close();
?>
</table>
我不确定这个页面是否是问题的一部分......
这是第二页
<?php
$host="XXXX"; // Host name
$username="XXXX"; // Mysql username
$password="XXXX"; // Mysql password
$db_name="XXXX"; // Database name
$tbl_name="XXXX"; // 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");
// get value of id that sent from address bar
$id=$_GET['id'];
// Retrieve data from database
$sql="SELECT * FROM $tbl_name WHERE id='$id'";
$result=mysql_query($sql);
$rows=mysql_fetch_array($result);
?>
<?php
$host="XXXX"; // Host name
$username="XXXX"; // Mysql username
$password="XXXX"; // Mysql password
$db_name="XXXX"; // Database name
$tbl_name="XXXX"; // 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");
// update data in mysql database
$sql="UPDATE `$host`.`$username`
SET `works` = `works` + 1 WHERE `$db_name`.`id` = '".$id."'";
$result=mysql_query($sql);
// if successfully updated.
if($result){
echo "Successful";
echo "<BR>";
echo "<a href='list_records.php'>View result</a>";
}
else {
echo "ERROR";
}
?>
我在我的自定义错误页面上收到错误,我不知道为什么.. 我试图让它添加 +1 到我的表上名为 works 的列默认值为 0,我无法添加它+1 表示值为 1,有人单击图像链接,值变为 2,再单击变为 3,依此类推
是的,这是真正的 mysql 登录信息,这不是我的烫发网站,它只是为了测试我的代码以放在我的真实网站上,所以我不在乎分享