<?php include("dbConfig.php");
if($_REQUEST['rowid']) {
$con_id = $_REQUEST['rowid']; //escape string //from the table this modal form is poped
echo "<form method='POST'>
<div class='form-group'>
<label for='servicename'>Service</label>
<input type='text' class='form-control'id='servicename' name='servicename' placeholder='Service'/>
</div>
<div class='form-group'>
<label for='serviceamount'>Amount</label>
<input type='text' class='form-control' id='serviceamount' name='amount' placeholder='Amount Collected'/>
</div>
</div>
<input type='submit' class='btn btn-primary' name='saveAmount' value='Save'/>
<button type='button' class='btn btn-default' data-dismiss='modal'>Close</button>
<?php
//this section is to save form contents after modal form is filled
if(isset($_POST['saveAmount'])){
$sql_content1='insert into peter_amount_tb (Amount,Income_id,ReceivedBy,ReceivedDate,Service) VALUE ('$Amount','$Income_id','ReceivedBy','ReceivedDate','Service')';
$sql_content_res1=mysqli_query($conn,$sql_content1);
$content_data=mysqli_fetch_array($sql_content_res1);
}?>
</form>";
}?>
// The last section where i want to post form contents posses problems
我已经看过类似的问题,但到目前为止,我没有修复我的问题。 请帮忙。我希望在行单击时弹出模态,在此表单上附带id,然后在代码snipet的最后部分保存到mysql数据库
答案 0 :(得分:0)
<?php
include("dbConfig.php");
if(isset($_POST['saveAmount'])){
$Amount =$_POST['amount'];
$Service =$_POST['servicename'];
$Income_id =$_REQUEST['rowid'];
$ReceivedBy="kabs"; //sample value
$sql_insert="insert into peter_amount_tb (Amount,Income_id,ReceivedBy,Service) VALUE ('$Amount','$Income_id','$ReceivedBy','$Service')";
if($res_insert=$conn->query($sql_insert)) { header("location: ppp.php"); }
echo $conn->error;
//$row_insert=$res_insert->fetch_assoc(); //($sql_content_res1);
}
if($_REQUEST['rowid']) {
$con_id = $_REQUEST['rowid']; //escape string
echo "<form method='POST' action='fetch_data_records.php'>
<div class='form-group'>
<input type='hidden' name='rowid' value = ".$con_id." />
<label for='servicename'>Service</label>
<input type='text' class='form-control' id='servicename' name='servicename' value=".$con_id." placeholder='Service'/>
</div>
<div class='form-group'>
<label for='serviceamount'>Amount</label>
<input type='text' class='form-control' id='serviceamount' name='amount' placeholder='Amount Collected'/>
</div>
</div>
<input type='submit' class='btn btn-primary' name='saveAmount' value='Save'/>
<button type='button' class='btn btn-default' data-dismiss='modal'>Close</button>
</form>";
}
?>