这是我的原始代码
<center>
<html>
<body>
<form method="post" name="AwardList" action="<?php echo $_SERVER['PHP_SELF']?>">
<table border=1>
<tr>
<th><b>Award</b></th>
<th><b>Issue ID</b></th>
<th><b>Sort #</b></th>
<th><b>Submit</b></th>
</tr>
<?php
$userid = ($vbulletin->userinfo['userid']);
$query = ("select a.*, userdisplayorder, issue_id from award a join award_user aw on a.award_id = aw.award_id where aw.userid = '$userid'");
if (isset($_POST['submit'])){
$userdisplayorder = mysql_real_escape_string($_POST['userdisplayorder']);
echo $_POST[issueid];
echo '<br>';
echo $userdisplayorder;
$sql = mysql_query("UPDATE award_user SET userdisplayorder='$userdisplayorder' WHERE issue_id='$_POST[issueid]'");
}
$result = mysql_query($query) or die(mysql_error());
$count = 1;
while ($row = mysql_fetch_array($result)){
$awardimgurl = $row['award_img_url'];
$ID = $row['issue_id'];
// don't get it from the database since its not unique in the database itself
// $userdisplayorder = $row['userdisplayorder'];
echo '<tr>';
echo '<th>';
echo "<img src='$awardimgurl'>"; echo '</th>';
echo '<th>';
echo '<input type="text" name="issueid" readonly="readonly" value="' . $ID . '" size="5">';
echo '</th>';
echo '<th>';
echo '<input type="text" name="userdisplayorder" value="' . $count . '" size="5">';
echo '</th>';
echo '<th>';
echo "<center><input type='submit' name='submit' value='Submit'></center>";
echo '</th>';
echo '</tr>';
$count ++;
}
?>
</table>
</html></center>
我还需要使 userdisplayorder 字段唯一。我已经拥有唯一的 issueid。我怎样才能做到这一点?请通过提供代码帮助我,我是 PHP 新手,只知道基础知识。我还不知道 PDO,我是视觉学习者,谢谢!