这是我的整个代码并且它可以工作,但我无法弄清楚如何使用此代码共享所有票据来处理当前按下的按钮...
$user = getUserData('users', 'Username');
$sql = "SELECT `Uplata`, `Dobivka`, `match1`, `match2`, `match3`, `match4`, `match5`, `match6`, `match7`, `match8`, `match9`, `match10`, `match11`, `match12`, `match13`, `match14`, `match15`, `match16`, `tip1`, `tip2`, `tip3`, `tip4`, `tip5`, `tip6`, `tip7`, `tip8`, `tip9`, `tip10`, `tip11`, `tip12`, `tip13`, `tip14`, `tip15`, `tip16`, `ticket_id`, `isActive`, `isShared` FROM `kladilnica` WHERE `Username`='$user'";
$result = $conn->query($sql);
$count = 0;
$uplata_total = 0;
if($result === false) {
echo "<b>Could not connect to database.</b>";
trigger_error('Wrong SQL: ' . $sql . ' Error: ' . $conn->error, E_USER_ERROR);
} else {
if($result->num_rows == 0) {
echo "<b>You do not have any tickets.</b>";
} else if($result->num_rows >= 1) {
$count = $count + 1;
while($row = $result->fetch_assoc()) {
if($result->num_rows != empty($row['match1'])) {
$uplata_total = $row["Uplata"];
$dobivka_total = $row["Dobivka"];
$ticket_id = $row["ticket_id"];
$is_active = $row["isActive"];
$shared = $row["isShared"];
if($is_active == 1) {
echo "<form action='home.php' method='POST'>";
echo "<table id='t02' style='margin-bottom: 10px;'><tr><th colspan='2'><input type='submit' name='share' class='share_button' value='Share'/></a></th></tr>";
echo "<tr><th colspan='2'>Ticket ".$count." <a style='position: relative; left: 69px;'>Ticket ID: ".$ticket_id."</a></th></tr>";
echo "
<tr><td>".$row["match1"]."</td><td>".$row["tip1"]."</td></tr>
<tr><td>".$row["match2"]."</td><td>".$row["tip2"]."</td></tr>
<tr><td>".$row["match3"]."</td><td>".$row["tip3"]."</td></tr>
<tr><td>".$row["match4"]."</td><td>".$row["tip4"]."</td></tr>
<tr><td>".$row["match5"]."</td><td>".$row["tip5"]."</td></tr>
<tr><td>".$row["match6"]."</td><td>".$row["tip6"]."</td></tr>
<tr><td>".$row["match7"]."</td><td>".$row["tip7"]."</td></tr>
<tr><td>".$row["match8"]."</td><td>".$row["tip8"]."</td></tr>
<tr><td>".$row["match9"]."</td><td>".$row["tip9"]."</td></tr>
<tr><td>".$row["match10"]."</td><td>".$row["tip10"]."</td></tr>
<tr><td>".$row["match11"]."</td><td>".$row["tip11"]."</td></tr>
<tr><td>".$row["match12"]."</td><td>".$row["tip12"]."</td></tr>
<tr><td>".$row["match13"]."</td><td>".$row["tip13"]."</td></tr>
<tr><td>".$row["match14"]."</td><td>".$row["tip14"]."</td></tr>
<tr><td>".$row["match15"]."</td><td>".$row["tip15"]."</td></tr>
<tr><td>".$row["match16"]."</td><td>".$row["tip16"]."</td></tr>
";
echo "<tr><th colspan='2'>Total Bet: $uplata_total</th></tr>";
echo "<tr><th colspan='2'>Total Win: $dobivka_total</th></tr>";
echo "</table>";
echo "</form>";
$count++;
}
}
if(isset($_POST['share'])) {
if($shared == 0) {
echo "Ticket shared sucessfully.";
$sql = "UPDATE `kladilnica` SET `isShared`=1 WHERE `ticket_id`='$ticket_id'";
$return = $conn->query($sql);
} else if($shared == 1) {
echo $ticket_id;
echo "Ticket already shared!";
}
}
}
}
}
$conn->close();
如果有人知道更好的分享流程,请与我分享:)