Hi, I'm having some trouble. I am fetching a list of "training tickets" from a table and each has its own transaction id for ease of coding. Everything appears as it should (though I'm in the very basics of tweaking that) but when I hit 'reject' it is deleting the wrong item from the table... despite the transaction id, so I'm very confused. It seems to work okay if I go from the bottom of the list up, but if I hit 'reject' on the first item on the list, it deletes the bottom one on the list.
$result = @mysql_query("SELECT transaction, player_id, owner_id, horse_id, accepted FROM training_tickets WHERE player_id='$player_id' AND accepted='0'")
or die("Cannot find pending requests! " . @mysql_error());
while($row = @mysql_fetch_array($result)):
$name = $row['game_name'];
$their_id = $row['owner_id'];
$transaction = $row['transaction'];
$horse_id = $row['horse_id'];
echo "<tr valign=top>
<form action='trainingtickets.php' method=post>
<input type=hidden name='transaction' value='$transaction'>
<td class='spage'><center><input type=submit name='accept' value='Accept!'></td>
<td class='spage'>For horse: <a href='horses.php?id=$horse_id'>$horsename (#$horse_id)</a></td>
<td class='spage'>Owned by: <a href='home.php?id=$their_id'>$name (#$their_id)</a> - $afford</td>
<td class='spage'><center><input type=submit name='reject' value='Reject!'></td></tr></form>";
endwhile;
$pending_flag = 1;
if(!$pending_flag){echo "<tr><td class='spage'>No pending training ticket requests.</td></tr>";}
echo "</table>";
if($_POST['reject']){
@mysql_query("DELETE FROM training_tickets WHERE transaction='$transaction' LIMIT 1")or die("Cannot delete pending training ticket request! " . @mysql_error());
if(@mysql_affected_rows()){
myConfirm("Training request denied.");
}else{myError("Invalid training request.");}
Are there any obvious errors? I have tried just about everything I could think of with no luck. I even had the transaction id appear in the form (i.e. it would post to trainingtickets.php?id=$transaction) and the transaction number would be correct for what I clicked, but it deleted something different from the table. Thanks in advance for help.