I need the $randNum
variable value after button click. but when the button is clicked the value is changed. when its echo the value its different from the table inserted value after the button clicked.
<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.........");
}
}
?>