这里是全码:需要一个手,像系统
<?php
session_start();
if(!isset($_SESSION["sess_user"])){
header("location:../logout.php");
} else {}
$user=$_SESSION['sess_user'];
?>
<?php
$con=mysql_connect('localhost','root','vertrigo') or die(mysql_error());
mysql_select_db('user_registration') or die("cannot select DB");
$sql=mysql_query("SELECT * FROM `likehand`");
while($likehandle = mysql_fetch_array($sql))
{
$fanname = $likehandle['Userlame'];
$Posid = $likehandle['Post_ID'];
}
?>
<?php
echo "<div style='background-color: #CC98CC'>";
echo "<tr align='center'bgcolor='#f0f0f0'>";
echo"<td><p align='center'><font size='1' color='black'><b>Welcome Back $user </b></a></font></p></td>";
echo "</tr>";
echo "</div>";
echo"<p align='center'><i><b>
<font style='opacity: 100' size='7' color='000000' face='forte'>News</font></b></i></p>";
include("newsdb.php");
if(isset($_POST['submit'])){
if(!empty($_POST['search'])) {
$srhuser=$_POST['search'];
$con=mysql_connect('localhost','root','vertrigo') or die(mysql_error());
mysql_select_db('user_registration') or die("cannot select DB");
$result=mysql_query("SELECT * FROM `news` where submitted_by='".$srhuser."'");}}
else{$result=mysql_query("SELECT * FROM `news`\n"
. " ORDER BY `code` DESC");
}
while($test = mysql_fetch_array($result))
{
$sbmitter = $test['submitted_by'];
$id = $test['code'];
$date = $test['date'];
$body = $test['body'];
$likes = $test['likes'];
$image = $test['url'];
$sql="SELECT * FROM `likehand`";
echo "<div style='background-color: #C0C0C0'>";
echo "<tr align='center'bgcolor='#f0f0f0'>";
echo"<td><i><left><font color='black'> $sbmitter Said:</center></font></i>";
echo"<td><p align='center'><font size='4' color='black'>$body</a></font></p></td>";
echo"<font color='Black'><p align='right'>created <a href='#'>";echo"<font color='blue'>";
echo date('d-m-Y \a\t\ g:i <b>a</b></a>', strtotime($test["date"])); // October 5, 2008 9:34 pm
echo" ";
$userid="$user-$id";
if("$fanname-$Posid" == $userid){echo"<td><p align='Left'><font size='2' color='black'>  $likes like <a href ='unlike.php?code=$id'><font color='black'><input type='button' value='Unlike' name='B3' style='width: 50; height: 20'></a></a></font></p></td>";
}else{ echo"<td><p align='Left'><font size='2' color='black'>  $likes like <a href ='like.php?code=$id'><font color='black'><input type='button' value='like' name='B3' style='width: 50; height: 20'></a></a></font></p></td>";
} if($sbmitter == $user)
{ echo"<td><p align='right'><font size='2' color='black'><a href ='adminpannel/postdel.php?code=$id'><font color='black'><input type='button' value='delete' name='B3' style='width: 50; height: 20'></a></a></font></td>";
echo"<td><font size='2' color='black'><a href ='/adminpannel/postedit.php?code=$id'><font color='black'><input type='button' value='edit' name='B3' style='width: 50; height: 20'></a></a></font></p></td>";
}
}
echo "</div>";
echo "<p></p>";
echo" ";
echo "</tr>";
mysql_close($conn);
?>
我认为这个问题是在这里,但不知道它是什么:
$userid="$user-$id";
if("$fanname-$Posid" == $userid){echo"<td><p align='Left'><font size='2' color='black'>  $likes like <a href ='unlike.php?code=$id'><font color='black'><input type='button' value='Unlike' name='B3' style='width: 50; height: 20'></a></a></font></p></td>";
}else{ echo"<td><p align='Left'><font size='2' color='black'>  $likes like <a href ='like.php?code=$id'><font color='black'><input type='button' value='like' name='B3' style='width: 50; height: 20'></a></a></font></p></td>";
}
我重新检查了数据库,并将其似乎它保存了正确的数据,问题是当用户按下像..喜欢字段增加一和帖子ID以及用户名被保存,但是当我喜欢多个帖子时,只有一个帖子显示“不同”按钮.. 有什么建议吗?
请在发布代码前介绍问题。这会让读者更容易理解这个问题。 –