按钮点击后我需要$randNum
变量值。但是当单击该按钮时,该值会更改。当它的回显值与点击按钮后的表插入值不同。
<input type="submit" class="btn btn-success btn-signin"
onClick="printDiv();" name="trConfirmed" id="trConfirmed" value="Print" />
<?php
$randNum = mt_rand(10, 100000);
echo($randNum); //I want to echo the $randNum here.
?>
<?php
/* ---- IF TRANSCATION CONFIRM BUTTON CLICK--- */
if (isset($_POST['trConfirmed'])) {
$sqlInsertInToTr = "INSERT INTO transactions (date_t,transaction_id,item_code,item_name,description,quantity,p_cost,sale_price,total_price)
SELECT CURDATE(),$randNum,item_code,item_name,description,quantity,p_cost,sale_price,total_price FROM tem_transaction ";
if ($db->dbQuery($sqlInsertInToTr)) { //need same $randNum value here
//echo("Transaction Confirmed-----");
echo "<meta http-equiv='refresh' content='0'>";
}
$deletFrmTmTr = "TRUNCATE tem_transaction";
if ($db->dbQuery($deletFrmTmTr)) {
//echo("deleted.........");
}
}
?>
答案 0 :(得分:-1)
如果发出POST和GET请求,将执行$ randNum值的打印代码。也许,在POST请求执行后,您会看到请求的GET结果。 在浏览器中跟踪有多少地址发生在php到该代码的文件