我有以下代碼,我試圖讓'Finalize Draft Order'提交按鈕僅在'Create Draft Order'按鈕被按下/設置時出現。現在,按下Create Create Order按鈕後,按鈕不會顯示出來。它只有當我把它拿出來,如果(isset功能的顯示如果isset語句沒有調出輸入字段
我在做什麼錯
<form method="POST" name="form">
<input type="submit" value="Create Draft Order" name="shuffle">
</form>
Shuffled results: <br>
<div class="main-bag">
<div class="shuffle_results" id="results"></div>
<form method="post">
<?php
$count = 0;
foreach ($array as $result) :
$count++;
$shuffle_count = $count;
$shuffle_firstname = htmlentities($result['firstname']);
$shuffle_lastname = htmlentities($result['lastname']);
$shuffle_id = htmlentities($result['id']);
$shuffle_username = htmlentities($result['username']);
$shuffle_email = htmlentities($result['email']);
?>
<input type="hidden" name="count[]" value="<?php echo $shuffle_count; ?>">
<input type="hidden" name="firstname[]" value="<?php echo $shuffle_firstname; ?>">
<input type="hidden" name="lastname[]" value="<?php echo $shuffle_lastname; ?>">
<input type="hidden" name="id[]" value="<?php echo $shuffle_id; ?>">
<input type="hidden" name="username[]" value="<?php echo $shuffle_username; ?>">
<input type="hidden" name="email[]" value="<?php echo $shuffle_email; ?>">
<?php
endforeach;
// only show this button if we have done a shuffle
if (isset($_POST['shuffle'])) :
echo '<input type="submit" value="Finalize Draft Order" name="insert">';
endif;
?>
更新:?
$array = array();
while ($row = mysqli_fetch_assoc($query)) {
$array[] = array(
'id' => $row['id'],
'firstname' => $row['firstname'],
'lastname' => $row['lastname'],
'username' => $row['username'],
'email' => $row['email']
);
if (isset($_POST['shuffle'])) {
}
}
shuffle($array);
echo json_encode($array);
你實際上沒有發佈shuffle作爲var。將它添加到您的輸入隱藏而不是按鈕的名稱 – ScottMcGready
我不確定您的意思。 – Becky
您的輸入提交按鈕被命名爲「shuffle」,但您發佈的數據不包含「shuffle」作爲後期變量/參數。 – ScottMcGready