I am new to php i'm trying to insert multiple values in database.I wrote my functions but it's throwing an error.I have attached my html form below.How can i solve this...
error showing:
A PHP Error was encountered
Severity: Notice
Message: Undefined index: itemNo
Filename: controllers/main.php
Line Number: 2406
My Code:
public function item_save(){
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("inventory", $con);
//$id_number = $_GET['id_user'];
$val1=$_GET['itemNo'];
$val2=$_GET['itemName'];
$val3=$_GET['quantity'];
$val4=$_GET['price'];
$val5=$_GET['total'];
$val6=$_GET['subTotal'];
$val7=$_GET['tax'];
$val8=$_GET['taxAmount'];
$val9=$_GET['totalAftertax'];
$val10=$_GET['amountPaid'];
$val1=$_GET['amountDue'];
$N = count($val1);
for($i=0; $i < $N; $i++)
{
mysql_query("INSERT INTO item_save(item_no,item_name,qty,price,total,subtotal,tax,tax_amount,total_final,amount_paid,amount_due) VALUES ('$val1[$i]','$val2[$i]','$val3[$i]','$val4[$i]','$val5[$i]','$val6','$val7','$val8','$val9','$val10','$val11')");
}
redirect("main/multiple");
}
form.html
<div class="container content">
<?php
echo form_open_multipart('main/item_save');
?>
<?php
$submit=array(
'name'=>'submit',
'type'=>'submit',
'class'=>'btn btn-primary',
'value'=>'Submit',
);
?>
<div class='row'>
<div class='col-xs-12 col-sm-12 col-md-12 col-lg-12'>
<table class="table table-bordered table-hover">
<thead>
<tr>
<th width="2%"><input id="check_all" class="formcontrol" type="checkbox"/></th>
<th width="15%">Item No</th>
<th width="38%">Item Name</th>
<th width="15%">Price</th>
<th width="15%">Quantity</th>
<th width="15%">Total</th>
</tr>
</thead>
<tbody>
<tr>
<td><input class="case" type="checkbox"/></td>
<td><input type="text" data-type="productCode" name="itemNo[]" id="itemNo_1" class="form-control autocomplete_txt" autocomplete="off"></td>
<td><input type="text" data-type="productName" name="itemName[]" id="itemName_1" class="form-control autocomplete_txt" autocomplete="off"></td>
<td><input type="number" name="price[]" id="price_1" class="form-control changesNo" autocomplete="off" onkeypress="return IsNumeric(event);" ondrop="return false;" onpaste="return false;"></td>
<td><input type="number" name="quantity[]" id="quantity_1" class="form-control changesNo" autocomplete="off" onkeypress="return IsNumeric(event);" ondrop="return false;" onpaste="return false;"></td>
<td><input type="number" name="total[]" id="total_1" class="form-control totalLinePrice" autocomplete="off" onkeypress="return IsNumeric(event);" ondrop="return false;" onpaste="return false;"></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class='row'>
<div class='col-xs-12 col-sm-3 col-md-3 col-lg-3'>
<button class="btn btn-danger delete" type="button">- Delete</button>
<button class="btn btn-success addmore" type="button">+ Add More</button>
</div>
<div class='col-xs-12 col-sm-offset-4 col-md-offset-4 col-lg-offset-4 col-sm-5 col-md-5 col-lg-5'>
<form class="form-inline">
<div class="form-group">
<label>Subtotal: </label>
<div class="input-group">
<div class="input-group-addon">$</div>
<input type="number" class="form-control" id="subTotal" name="subTotal" placeholder="Subtotal" onkeypress="return IsNumeric(event);" ondrop="return false;" onpaste="return false;">
</div>
</div>
<div class="form-group">
<label>Tax: </label>
<div class="input-group">
<div class="input-group-addon">$</div>
<input type="number" class="form-control" id="tax" name="tax" placeholder="Tax" onkeypress="return IsNumeric(event);" ondrop="return false;" onpaste="return false;">
</div>
</div>
<div class="form-group">
<label>Tax Amount: </label>
<div class="input-group">
<input type="number" class="form-control" id="taxAmount" name="taxAmount" placeholder="Tax" onkeypress="return IsNumeric(event);" ondrop="return false;" onpaste="return false;">
<div class="input-group-addon">%</div>
</div>
</div>
<div class="form-group">
<label>Total: </label>
<div class="input-group">
<div class="input-group-addon">$</div>
<input type="number" class="form-control" id="totalAftertax" name="totalAftertax" placeholder="Total" onkeypress="return IsNumeric(event);" ondrop="return false;" onpaste="return false;">
</div>
</div>
<div class="form-group">
<label>Amount Paid: </label>
<div class="input-group">
<div class="input-group-addon">$</div>
<input type="number" class="form-control" id="amountPaid" name="amountPaid" placeholder="Amount Paid" onkeypress="return IsNumeric(event);" ondrop="return false;" onpaste="return false;">
</div>
</div>
<div class="form-group">
<label>Amount Due: </label>
<div class="input-group">
<div class="input-group-addon">$</div>
<input type="number" class="form-control amountDue" id="amountDue" name="amountDue" placeholder="Amount Due" onkeypress="return IsNumeric(event);" ondrop="return false;" onpaste="return false;">
</div>
</div>
</form>
</div>
<?php echo form_submit($submit);?>
</div>
</div>
Notice: Undefined index: itemNo means that your $_GET['itemNo']; is not set.
You probably forgot to add &itemNo=xxx in your URL, but looking to the rest of your code you are missing itemNo[] GET parameter from form (I guess checkboxes).
EDIT:
Now, after you posted HTML, and I still don't see <form> tag, let me ask you. Are you sure you are using GET method? Because multipart forms are usually using POST method.
Check your HTML output (as source code in browser), or some network debugging and check wether it's POST or GET. I bet that it's POST, but you try to retrieve GET.
Also, you can try change $_GET to $_REQUEST (matches both GET and POST), but that's not the best idea.
Related
Bootstrap columns not taking in print page and aligned wrongly how to rectify this issue?
I dont need responsive page but need to align the print page. Can anyone plz help me out?
#media print {
#page {
margin: 2cm;
}
.col-md-1,.col-md-2,.col-md-3,.col-md-4,
.col-md-5,.col-md-6,.col-md-7,.col-md-8,
.col-md-9,.col-md-10,.col-md-11,.col-md-12 {
float: left;
}
.col-md-1 {
width: 8%;
}
.col-md-2 {
width: 16%;
}
.col-md-3 {
width: 25%;
}
.col-md-4 {
width: 33%;
}
.col-md-5 {
width: 42%;
}
.col-md-6 {
width: 50%;
float: left;
}
.col-md-7 {
width: 58%;
}
.col-md-8 {
width: 66%;
}
.col-md-9 {
width: 75%;
}
.col-md-10 {
width: 83%;
}
.col-md-11 {
width: 92%;
}
.col-md-12 {
width: 100%;
}
}
HTML PAGE
[<div class="container border border-dark" id="container">
<div class="row">
<div style="font-size:25px; font-weight:bold; text-decoration: underline;" class="col-md-10">KERCHANSHE TRADING PLC
<div style="font-size:15px;margin-right: 5px;margin-left: 34px;"><i class="fa fa-mobile" style="font-size:18px;margin-right: 5px;" aria-hidden="true"></i> 091 121 2436
<i class="fa fa-phone" style="font-size:18px;margin-right: 5px;margin-left: 31px;" aria-hidden="true"></i> 011 371 6370</div>
<div style="font-size:15px;margin-left: 80px;">Addis Ababa, Ethiopia</div>
</div>
<div style="font-size:20px; font-weight:bold; border: 1px solid black;text-align: center;height: min-content;"
class="col-md-2 border border-dark">ORIGNAL</div>
</div>
<div class="form-group">
<input type="text" class="form-control" placeholder="MinVal">
</div>
<div class="form-group">
<input type="text" class="form-control" placeholder="MaxVal">
</div>
<div class="row">
<div class="col-md-6"></div>
<div class="col-md-4" style="margin-left: 18px;">
<div class="input-group input-group-sm mb-3">
<div class="input-group-prepend">
<span class="input-group-text" id="inputGroup-sizing-sm">Cert. No</span>
</div>
<input type="text" id="cert1_no" class="form-control input-sm" aria-label="Small" aria-describedby="inputGroup-sizing-sm">
</div>
</div>
</div>
<div class="row">
<div class="col-md-6"></div>
<div class="col-md-4" style="margin-left: 18px;">
<div class="input-group input-group-sm mb-3">
<div class="input-group-prepend">
<span class="input-group-text" id="inputGroup-sizing-sm">Addis Ababa</span>
</div>
<input type="text" id="addis_ababa" class="form-control input-sm" aria-label="Small" aria-describedby="inputGroup-sizing-sm">
</div>
</div>
</div>
<div class="row">
<div class="col-xl-5 col-lg-6 col-md-8 col-sm-10 mx-auto text-center form p-4">
<span style="font-size:30px; font-weight:bold; text-decoration: underline;">CERTIFICATE</span>
</div>
</div>
<span style="font-size:20px; text-decoration: underline;margin-left: 19%;">
<b>CERTIFICATE OF CLEANLINESS AND GRADE OF ETHIOPIAN COFFEE</b>
</span><br/><br/>
<div class="row">
<div class="col-md-3">
<input name="origin" type="text" class="form-control" id="origin_cert1"/>
<span style="">(Origin)</span>
</div>
<div class="col-md-9">
<span class="pull-right"> <input name="grade" type="text" class="form-control" id="grade_cert1"/>
<span style="">(Grade)</span>
</span>
</div>
</div>
<br>
<div style="font-size:15px;">
<p style="text-align: center;font-weight: 700; font-size: 18px;">Description of Lot</p>
<table class="table tablecert1 table-bordered">
<tr>
<th colspan="4" style="text-align: center;">BAGS</th>
</tr>
<tr>
<th rowspan="2" style="text-align: center;">No</th>
<th colspan="2" style="text-align: center;">Weight</th>
<th rowspan="2" style="text-align: center;">Mark</th>
</tr>
<tr>
<th style="text-align: center;">Gross</th>
<th style="text-align: center;">Net</th>
</tr>
<tr>
<td><input style="" id="no_1" class="form-control no" type="text"></td>
<td><input style="" id="gross_1" class="form-control gross" type="text"></td>
<td><input style="" id="net_1" class="form-control net" type="text"></td>
<td><input style="" id="mark_1" class="form-control mark" type="text"></td>
</tr>
<tr>
<td><input style="" id="no_2" class="form-control no" type="text"></td>
<td><input style="" id="gross_2" class="form-control gross" type="text"></td>
<td><input style="" id="net_2" class="form-control net" type="text"></td>
<td><input style="" id="mark_2" class="form-control mark" type="text"></td>
</tr>
<tr>
<td><input style="" id="no_3" class="form-control no" type="text"></td>
<td><input style="" id="gross_3" class="form-control gross" type="text"></td>
<td><input style="" id="net_3" class="form-control net" type="text"></td>
<td><input style="" id="mark_3" class="form-control mark" type="text"></td>
</tr>
<tr>
<td><input style="" id="no_4" class="form-control no" type="text"></td>
<td><input style="" id="gross_4" class="form-control gross" type="text"></td>
<td><input style="" id="net_4" class="form-control net" type="text"></td>
<td><input style="" id="mark_4"class="form-control mark" type="text"></td>
</tr>
<tr>
<td><input style="" id="no_5" class="form-control no" type="text"></td>
<td><input style="" id="gross_5" class="form-control gross" type="text"></td>
<td><input style="" id="net_5" class="form-control net" type="text"></td>
<td><input style="" id="mark_5" class="form-control mark" type="text"></td>
</tr>
<tr>
<td><input style="" id="no_6" class="form-control no" type="text"></td>
<td><input style="" id="gross_6" class="form-control gross" type="text"></td>
<td><input style="" id="net_6" class="form-control net" type="text"></td>
<td><input style="" id="mark_6" class="form-control mark" type="text"></td>
</tr>
</table>
</table>
</div>
<div class="row">
<div class="input-group mb-1 col-md-6">
<div class="input-group-prepend">
<span class="input-group-text" id="basic-addon1">Driver's Name</span>
</div>
<input type="text" class="form-control" id="driversname" aria-label="Username" aria-describedby="basic-addon1">
</div>
</div>
<div class="row">
<div class="input-group mb-1 col-md-6">
<div class="input-group-prepend">
<span class="input-group-text" id="basic-addon1">Truck Plate No.</span>
</div>
<input type="text" class="form-control" id="truckplateno" aria-label="Username" aria-describedby="basic-addon1">
</div>
</div>
<div class="row">
<div class="input-group mb-1 col-md-6">
<div class="input-group-prepend">
<span class="input-group-text" id="basic-addon1">Trailer No.</span>
</div>
<input type="text" class="form-control" id="trailerno" aria-label="Username" aria-describedby="basic-addon1">
</div>
</div>
<div class="row">
<div class="input-group mb-1 col-md-6">
<div class="input-group-prepend">
<span class="input-group-text" id="basic-addon1">Container No.</span>
</div>
<input type="text" class="form-control" id="containerno" aria-label="Username" aria-describedby="basic-addon1">
</div>
<div class="form-inline">
<label for="exampleInputEmail1" style="MARGIN-LEFT: 50PX;font-weight: 700;text-decoration:overline;">KERCHANSHE TRADING PLC</label>
</div>
</div>
<div class="row">
<div class="input-group mb-1 col-md-6">
<div class="input-group-prepend">
<span class="input-group-text" id="basic-addon1">Seal No.</span>
</div>
<input type="text" class="form-control" id="sealno" aria-label="Username" aria-describedby="basic-addon1">
</div>
</div><br>
<div class="row">
<div class="form-group form-inline">
<label for="exampleInputEmail1" style="MARGIN-LEFT: 550PX;font-weight: 700;text-decoration:overline;">Signature of Licensed Coffee Cleaners & Graders</label>
</div>
</div>
</div>][1]
I have attached my print page please find it. And suggest me where i have to change the code in media print in css??
Actually the page should like this
real page should be like this
print wrong page looks like
print page
function printDiv_kerch() {
var divToPrint = document.getElementById('container');
var newWin = window.open('', 'Print-Window', '');
newWin.document.open();
newWin.document.write('<html><head>');
newWin.document.write('<link rel="stylesheet" type="text/css" media="print" href="http://localhost/verbat/css/certi.css"></head>');
newWin.document.write('<link rel="stylesheet" type="text/css" media="print" href="http://localhost/verbat/bootstrap-4.3.1-dist/bootstrap.min.css"></head>');
newWin.document.write('<body style="" onload="window.print();window.close();">' + divToPrint.innerHTML + '');
newWin.document.write('</body></html>');
newWin.document.close();
setTimeout(function() {
newWin.close();
}, 500);
}
I want to store form array value. but it giving some errors please help
receiving error
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'product_name' cannot be null (SQL: insert into bill_products (product_name, bill_no, suppliers_master_id, suppliers_unic_id, party_id, supplier_name, GSTIN, bill_date, bill_entry_date, qty, HSN_SAC, sale_rate, MRP_rate, purchase_rate, part_no, updated_at, created_at) values (?, 111w, master_5499384803, unic_5764728886, PARTY-NO922826, dvfd, fg99, 06-08-2020, 15-08-2020, 1, 1, 11, 1, 1, 1, 2020-08-15 16:24:28, 2020-08-15 16:24:28))
This is my controller
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'product_name' cannot be null (SQL: insert into `Item_list`
This is my controller
public function purchaseentryformsave(Request $request)
{
$purchasen=new Purchase;
$purchasen->supplier_name = $request->supplier_name;
$purchasen->bill_no = $request->bill_no;
$purchasen->suppliers_master_id = $request->suppliers_master_id;
$purchasen->party_id = $request->party_id;
$purchasen->GSTIN = $request->GSTIN;
$purchasen->bill_date = $request->bill_date;
$purchasen->bill_entry_date = $request->bill_entry_date;
$purchasen->total_bill_amount = $request->total_bill_amount;
$purchasen->phone = $request->phone;
$purchasen->pincode = $request->pincode;
$purchasen->state = $request->state;
$purchasen->address = $request->address;
$purchasen->suppliers_unic_id = $request->suppliers_unic_id;
if ($purchasen->save()){
$product_name = $purchasen->product_name;
$bill_no = $purchasen->bill_no;
$suppliers_master_id = $purchasen->suppliers_master_id;
$suppliers_unic_id = $purchasen->suppliers_unic_id;
$party_id = $purchasen->party_id;
$supplier_name = $purchasen->supplier_name;
$GSTIN = $purchasen->GSTIN;
$bill_date = $purchasen->bill_date;
$bill_entry_date = $purchasen->bill_entry_date;
foreach($request->qty as $k => $p){
Billproduct::create([
'product_name' => $product_name,
'bill_no' => $bill_no,
'suppliers_master_id' => $suppliers_master_id,
'suppliers_unic_id' => $suppliers_unic_id,
'party_id' => $party_id,
'supplier_name' => $supplier_name,
'GSTIN' => $GSTIN,
'bill_date' => $bill_date,
'bill_entry_date' => $bill_entry_date,
'qty' => $request['qty'][$k],
'HSN_SAC' => $request['HSN_SAC'][$k],
'sale_rate' => $request['sale_rate'][$k],
'MRP_rate' => $request['MRP_rate'][$k],
'purchase_rate' => $request['purchase_rate'][$k],
'part_no' => $request['part_no'][$k],
]);
}
foreach($request->qty as $g => $p){
Item_list::create([
'supplier_name' => $supplier_name,
'product_name' => $product_name,
'qty' => $request['qty'][$g],
'purchase_rate' => $request['purchase_rate'][$g],
'MRP_rate' => $request['MRP_rate'][$g],
'sale_rate' => $request['sale_rate'][$g],
'part_no' => $request['part_no'][$g],
]);
}
}
return back()->with('success',' NEW PURCHASE ADDED SUCCESSFULLY .');
}
this is my view
<div class="container">
<div class="row justify-content-center">
<div class="col-md-12">
<div class="card">
<div class="card-header">PURCHASE FORM</div>
<div class="card-body">
#if (Session::has('success'))
<div class="alert alert-success">{!! Session::get('success') !!}</div>
#endif
#if (Session::has('failure'))
<div class="alert alert-danger">{!! Session::get('failure') !!}</div>
#endif
<form method="POST" action="{{route('purchaseentryformsave')}}" enctype="multipart/form-data">
#csrf
<input type="text"style="background-color:yellow ;" class="form-control " name="suppliers_master_id" placeholder="SUPPLIER NAME" value="{{ $Supplierdata->suppliers_master_id }}" hidden>
<input type="text"style="background-color:yellow ;" class="form-control " name="suppliers_unic_id" placeholder="SUPPLIER NAME" value="{{ $Supplierdata->suppliers_unic_id }}" hidden>
<input type="text"style="background-color:yellow ;" class="form-control " name="GSTIN" placeholder="SUPPLIER NAME" value="{{ $Supplierdata->GSTIN }}" hidden>
<input type="text"style="background-color:yellow ;" class="form-control " name="phone" placeholder="SUPPLIER NAME" value="{{ $Supplierdata->phone }}" hidden>
<input type="text"style="background-color:yellow ;" class="form-control " name="pincode" placeholder="SUPPLIER NAME" value="{{ $Supplierdata->pincode }}" hidden>
<input type="text"style="background-color:yellow ;" class="form-control " name="state" placeholder="SUPPLIER NAME" value="{{ $Supplierdata->state }}" hidden>
<input type="text"style="background-color:yellow ;" class="form-control " name="address" placeholder="SUPPLIER NAME" value="{{ $Supplierdata->address }}" hidden>
<div class="form-row">
<div class="col-md-4 mb-3">
<label for="validationServer01">SUPPLIER NAME</label>
<input type="text"style="background-color:yellow ;" class="form-control " name="supplier_name" id="validationServer01" placeholder="SUPPLIER NAME" value="{{ $Supplierdata->supplier_name }}" required >
</div>
<div class="col-md-2 mb-3">
<label for="validationServer01">PARTY-NO</label>
<input type="text" style="background-color:yellow ;" class="form-control" name="party_id" id="validationServer01" placeholder="PARTY-NO" value="{{ $Supplierdata->party_id}}" required >
</div>
<div class="col-md-2 mb-3">
<label for="validationServer01">BILL DATE</label>
<input type=" " class="form-control " name="bill_date" id="date" placeholder="BILL DATE" value="" required >
</div>
<div class="col-md-2 mb-3">
<label for="validationServer01">BILL ENTRY DATE</label>
<input type="" class="form-control " name="bill_entry_date" placeholder="BILL DATE" value="<?php echo date('d-m-yy'); ?>" required>
</div>
<div class="col-md-2 mb-3">
<label for="validationServer01">BILL NO</label>
<input type="text" class="form-control " name="bill_no" id="validationServer01" placeholder="BILL NO" value="" required >
</div>
</div>
<div class="form-row">
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
th, td {
padding: 5px;
text-align: left;
}
</style>
<style>
table thead { display:block; }
table tbody { height:250px; overflow-y:scroll; display:block; }
</style>
</div>
<table id="tableAppointment" style="background-color:powderblue;">
<tr>
<th style="text-align:center;" colspan="1">Description of Goods</th>
<th style="text-align:center;" colspan="1">HSN/SAC</th>
<th style="text-align:center;" colspan="1">MRP</th>
<th style="text-align:center;" colspan="1">Part No</th>
<th style="text-align:center;" colspan="1">Qty</th>
<th style="text-align:center;" colspan="1">GST</th>
<th style="text-align:center;" colspan="1">Rate</th>
<th style="text-align:center;" colspan="1">Sale Rate</th>
<th style="text-align:center;" colspan="1">Amout</th>
</tr>
<tr>
<td ><input style="text-align:center;" type="text" class="text-danger form-control " name="product_name[]" id="validationServer01" placeholder="Item" value="" required autocomplete="off" ></td>
<td ><input style="text-align:center;" type="text" class="text-danger input-lg form-control " name="HSN_SAC[]" id="validationServer01" placeholder="HSN/SAC" value="" required autocomplete="off"></td>
<td > <input style="text-align:center;" type="text" class="form-control " name="MRP_rate[]" id="validationServer01" placeholder="MRP" value="" required pattern="[1-2-3-4-3-5-6-7-8-9-10-12]+"numbers="onlynumbers"></td>
<td > <input style="text-align:center;" type="text" class="text-danger input-lg form-control " name="part_no[]" id="validationServer01" placeholder="PART-NO" value="" required autocomplete="off"></td>
<td > <input style="text-align:center;" type="text" class="text-danger input-lg form-control quantity" name="qty[]" id="validationServer01" placeholder="QTY" value="" required pattern="[1-2-3-4-3-5-6-7-8-9-10-12]+"numbers="onlynumbers" autocomplete="off"></td>
<td > <input style="text-align:center;" type="text" class="text-danger input-lg form-control gst " name="gst_amount[]" id="validationServer01" placeholder="GST" value="" required pattern="[1-2-3-4-3-5-6-7-8-9-10-12]+"numbers="onlynumbers" autocomplete="off"></td>
<td > <input style="text-align:center;" type="text" class="text-danger input-lg form-control price" name="purchase_rate[]" id="validationServer01" placeholder="RATE" value="" required pattern="[1-2-3-4-3-5-6-7-8-9-10-12]+"numbers="onlynumbers" autocomplete="off"></td>
<td > <input style="text-align:center;" type="text" class="text-danger input-lg form-control " name="sale_rate[]" id="validationServer01" placeholder="Sale Rate" value="" required pattern="[1-2-3-4-3-5-6-7-8-9-10-12]+"numbers="onlynumbers" autocomplete="off"></td>
<td > <input style="text-align:center;" type="text" class="text-danger input-lg form-control totalamount" name="" id="validationServer01" placeholder="AMOUNT" value="" required pattern="[1-2-3-4-3-5-6-7-8-9-10-12]+"numbers="onlynumbers" disabled></td>
</tr>
<tr>
<td ><input style="text-align:center;" type="text" class="text-danger form-control " name="product_name[]" id="validationServer01" placeholder="Item" value="" required autocomplete="off" ></td>
<td ><input style="text-align:center;" type="text" class="text-danger input-lg form-control " name="HSN_SAC[]" id="validationServer01" placeholder="HSN/SAC" value="" required autocomplete="off"></td>
<td > <input style="text-align:center;" type="text" class="form-control " name="MRP_rate[]" id="validationServer01" placeholder="MRP" value="" required pattern="[1-2-3-4-3-5-6-7-8-9-10-12]+"numbers="onlynumbers"></td>
<td > <input style="text-align:center;" type="text" class="text-danger input-lg form-control " name="part_no[]" id="validationServer01" placeholder="PART-NO" value="" required autocomplete="off"></td>
<td > <input style="text-align:center;" type="text" class="text-danger input-lg form-control quantity" name="qty[]" id="validationServer01" placeholder="QTY" value="" required pattern="[1-2-3-4-3-5-6-7-8-9-10-12]+"numbers="onlynumbers" autocomplete="off"></td>
<td > <input style="text-align:center;" type="text" class="text-danger input-lg form-control gst " name="gst_amount[]" id="validationServer01" placeholder="GST" value="" required pattern="[1-2-3-4-3-5-6-7-8-9-10-12]+"numbers="onlynumbers" autocomplete="off"></td>
<td > <input style="text-align:center;" type="text" class="text-danger input-lg form-control price" name="purchase_rate[]" id="validationServer01" placeholder="RATE" value="" required pattern="[1-2-3-4-3-5-6-7-8-9-10-12]+"numbers="onlynumbers" autocomplete="off"></td>
<td > <input style="text-align:center;" type="text" class="text-danger input-lg form-control " name="sale_rate[]" id="validationServer01" placeholder="Sale Rate" value="" required pattern="[1-2-3-4-3-5-6-7-8-9-10-12]+"numbers="onlynumbers" autocomplete="off"></td>
<td > <input style="text-align:center;" type="text" class="text-danger input-lg form-control totalamount" name="" id="validationServer01" placeholder="AMOUNT" value="" required pattern="[1-2-3-4-3-5-6-7-8-9-10-12]+"numbers="onlynumbers" disabled></td>
</tr>
</table>
<br>
<div class="row justify-content-between">
<div class="text-danger col-md-2 offset-md-10">
<b>VALVE OF GOODS</b>
</div>
</div>
<div class="row justify-content-between">
<div class="col-md-2 offset-md-10"> <input type="text" class=" text-danger form-control total" name="total_bill_amount" id="validationServer01" placeholder=" VALVE OF GOODS" required >
</div>
</div>
<hr>
<button class="btn btn-primary float-right" type="submit">SAVE</button>
</form>
<a style='margin-right:40px' class="btn btn-secondary float-right" href="{{ route('allpurchasesupplierlist') }}" role="button">BACK</a>
</div>
</div>
</div>
</div>
</div>
this is my route
Route::get('purchaseentryform{id}', 'PurchaseController#purchaseentryform')->name('purchaseentryform');
Route::post('purchaseentryformsave', 'PurchaseController#purchaseentryformsave')->name('purchaseentryformsave');
my model
Billproduct
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Billproduct extends Model
{
protected $table = 'bill_products';
protected $fillable = ['supplier_name','suppliers_master_id','suppliers_unic_id','GSTIN','party_id','bill_no','bill_entry_date','bill_date','product_name','qty','purchase_rate','MRP_rate','supplier_name','sale_rate','HSN_SAC','part_no'];
}
my model
**Item_list **
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Item_list extends Model
{
protected $table = 'item_lists';
protected $fillable = ['product_name','qty','purchase_rate','MRP_rate','sale_rate','supplier_name','part_no'];
}
my model
**Purchase **
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Purchase extends Model
{
protected $table = 'purchases';
protected $fillable = ['suppliers_master_id','suppliers_unic_id','party_id','supplier_name','GSTIN','bill_no','bill_date','bill_entry_date','total_bill_amount','phone','pincode','state','address','delete_states','part_no'];
}
You should add $purchasen->product_name = $request->product_name; before if ($purchasen->save())
$purchasen=new Purchase;
$purchasen->product_name = $request->product_name;
Then
if ($purchasen->save()){
$product_name = $purchasen->product_name;
}
I have a dynamically added multiple row table that created using php and jQuery.html & jquery working fine. but,when I insert the data into the database, it works only for single row. when i want to add multiple rows it shows error.
when i want to insert multiple rows it works only for the first row and shows error ....
Fatal error: Uncaught PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'button_line' cannot be null in E:\xampp\htdocs\atiq\New-Project\ButtonTexMine\name.php:47 Stack trace: #0 E:\xampp\htdocs\atiq\New-Project\ButtonTexMine\name.php(47): PDOStatement->execute(Array) #1 {main} thrown in E:\xampp\htdocs\atiq\New-Project\ButtonTexMine\name.php on line 47
anybody please help ? My insert queries are as below:
<form action="name.php" method="post" name="add_name" id="add_name">
<div class="row" id="div1" style="background-color:#fafbf6;color:#000;">
<div class="col-xs-2">
<div class="form-group">
<label>Date</label>
<div>
<div class="input-group">
<input name="date" type="text" class="form-control" placeholder="mm/dd/yyyy" id="datepicker-autoclose">
<span class="input-group-addon bg-custom b-0"><i class="mdi mdi-calendar text-white"></i></span>
</div><!-- input-group -->
</div>
</div>
</div>
<div class="col-xs-2">
<div class="form-group">
<label>Party Name</label>
<input type="text" class="form-control" maxlength="100" name="party_name" id="placement" />
</div>
</div>
<div class="col-xs-2">
<div class="form-group">
<label>Party Address</label>
<input type="text" class="form-control" maxlength="500" name="party_address" id="placement" />
</div>
</div>
<div class="col-xs-2">
<div class="form-group">
<label>Party Ref</label>
<input type="text" class="form-control" maxlength="100" name="party_ref" id="placement" />
</div>
</div>
<div class="col-xs-2">
<div class="form-group">
<label>Work Order No</label>
<input type="text" class="form-control" maxlength="30" name="won" id="placement" />
</div>
</div>
<div class="col-xs-2">
<div class="form-group">
<label>Work Order Off</label>
<input type="text" class="form-control" maxlength="100" name="woof" id="placement" />
</div>
</div>
</div>
<div class="row" id="div1" style="background-color:#fafbf6;color:#000;">
<div class="table-responsive">
<table class="table table-bordered" id="dynamic_field">
<thead>
<th>Button Line</th>
<th>Button Hole</th>
<th>Button Type</th>
<th>Logo Button</th>
<th>Qty</th>
<th>Rate</th>
<th>Amount</th>
<th>Revised Rate</th>
<th>Revised Amount</th>
<th></th>
</thead>
<tbody>
<tr>
<td><select name="button_line[]" class="form-control name_list">
<option value=''>Select Option</option>
<option value="14L">14L</option>
<option value="16L">16L</option>
<option value="18L">18L</option>
<option value="20L">20L</option>
<option value="22L">22L</option>
<option value="24L">24L</option>
<option value="26L">26L</option>
<option value="28L">28L</option>
<option value="30L">30L</option>
<option value="32L">32L</option>
<option value="36L">36L</option>
<option value="40L">40L</option>
<option value="44L">44L</option>
<option value="48L">48L</option>
<option value="54L">54L</option>
<option value="60L">60L</option>
</select> </td>
<td><select name="button_hole[]" class="form-control name_list">
<option value=''>Select Option</option>
<option value='2'>2</option>
<option value='3'>3</option>
<option value='4'>4</option>
<option value='others'>Otheres</option>
</select> </td>
<td><select name="button_type[]" class="form-control name_list">
<option value=''>Select Option</option>
<option value='Pearl'>Pearl</option>
<option value='Chalk'>Chalk</option>
<option value='Horn'>Horn</option>
<option value='T.P.T'>T.P.T</option>
</select> </td>
<td><select name="logo_button[]" class="form-control name_list">
<option value=''>Select Option</option>
<option value='yes'>Yes</option>
<option value='no'>No</option>
</select> </td>
<td><input type="text" name="qty[]" id="qty0" onchange="sum(0)" placeholder="Enter your Qty" class="form-control name_list" /></td>
<td><input type="text" name="rate[]" id="rate0" onchange="sum(0)" placeholder="Enter your Rate" class="form-control name_list" /></td>
<td><input type="text" name="total[]" id="sum0" class="form-control name_list" /></td>
<td><input type="text" name="r_rate[]" id="Rrate0" onchange="sum(0)" placeholder="Enter your Rate" class="form-control name_list" /></td>
<td><input type="text" name="r_amount[]" id="Rsum0" class="form-control name_list" /></td>
<td><button type="button" name="add" id="add" class="btn btn-success">Add More</button></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="row">
<div class="col-xs-2">
<div class="form-group">
<label>Proforma Invoice Number</label>
<input type="text" class="form-control" maxlength="30" name="pro_in_no" id="placement" />
</div>
</div>
<div class="col-xs-2">
<div class="form-group">
<label>Proforma Invoice Date</label>
<input type="text" class="form-control" maxlength="30" name="pro_in_date" id="placement" />
</div>
</div>
<div class="col-xs-2">
<div class="form-group">
<label>Cash Bill Number</label>
<input type="text" class="form-control" maxlength="100" name="cash_bill_no" id="" />
</div>
</div>
<div class="col-xs-2">
<div class="form-group">
<label>LC SL No</label>
<input type="text" class="form-control" maxlength="30" name="lc_sl_no" id="" />
</div>
</div>
<div class="col-xs-2">
<div class="form-group">
<label>LC No</label>
<input type="text" class="form-control" maxlength="30" name="lc_no" id="" />
</div>
</div>
<div class="col-xs-2">
<div class="form-group">
<label>LC Date</label>
<input type="text" class="form-control" maxlength="30" name="lc_date" id="placement" />
</div>
</div>
<div class="col-xs-2">
<div class="form-group">
<label>Total Amount</label>
<input type="text" class="form-control" maxlength="30" name="total_amount" id="allsum" />
</div>
</div>
<div class="col-xs-2">
<div class="form-group">
<label>Pay Amount</label>
<input type="text" class="form-control" maxlength="30" name="pay_amount" id="pay" />
</div>
</div>
<div class="col-xs-2">
<div class="form-group">
<label>Due</label>
<input type="text" class="form-control" maxlength="30" name="due" id="dueA" readonly />
</div>
</div>
<div class="col-xs-2">
<div class="form-group">
<label>Mode of Payment</label>
<select name="mode" class="form-control select2">
<option>Select</option>
<option value="Cash">Cash</option>
<option value="LC">LC</option>
</select>
</div>
</div>
<div class="col-xs-2">
<div class="form-group">
<div class="modal-footer">
<input type="submit" name="submit" id="submit" class="btn btn-info" value="Submit" />
</div>
</div>
</div>
</div>
</form>
<script>
var i=0;
$(document).ready(function(){
$('#add').click(function(){
i++;
$('#dynamic_field').append('<tr id="row'+i+'"><td><select name="button_line['+i+']" class="form-control name_list"><option value="">Select Option</option><option value="14L">14L</option><option value="16L">16L</option><option value="18L">18L</option><option value="20L">20L</option><option value="22L">22L</option><option value="24L">24L</option><option value="26L">26L</option><option value="28L">28L</option><option value="30L">30L</option><option value="32L">32L</option><option value="36L">36L</option><option value="40L">40L</option><option value="44L">44L</option><option value="48L">48L</option><option value="54L">54L</option><option value="60L">60L</option></select></td><td><select name="button_hole['+i+']" class="form-control name_list"><option value="#">Select Option</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="others">Otheres</option></select> </td><td><select name="button_type['+i+']" class="form-control name_list"><option value="#">Select Option</option><option value="Pearl">Pearl</option><option value="Chalk">Chalk</option><option value="Horn">Horn</option><option value="T.P.T">T.P.T</option></select></td><td><select name="logo_button[]" class="form-control name_list"><option value="#">Select Option</option><option value="yes">Yes</option><option value="no">No</option></select></td><td><input type="text" name="qty['+i+']" id="qty'+i+'" onchange="sum(0)" placeholder="Enter your Qty" class="form-control name_list" /></td><td><input type="text" name="rate['+i+']" id="rate'+i+'" onchange="sum(0)" placeholder="Enter your Rate" class="form-control name_list" /></td><td><input type="text" name="total[]" id="sum'+i+'" class="form-control name_list" /></td><td><input type="text" name="r_rate[]" id="rate0" onchange="sum(0)" placeholder="Enter your Rate" class="form-control name_list" /></td><td><input type="text" name="r_amount[]" id="sum0" class="form-control name_list"/></td><td><button type="button" name="remove" id="'+i+'" class="btn btn-danger btn_remove">X</button></td></tr>');
$('#qty'+i+', #rate'+i).change(function() {
sum(i)
});
});
$(document).on('click', '.btn_remove', function(){
var button_id = $(this).attr("id");
$('#row'+button_id+'').remove();
sum_total();
});
$('#submit').click(function(){
$.ajax({
url:"name.php",
method:"POST",
data:$('#add_name').serialize(),
success:function(data)
{
alert(data);
$('#add_name')[0].reset();
}
});
});
});
$(document).ready(function() {
//this calculates values automatically
sum(0);
});
function sum(i) {
var qty1 = document.getElementById('qty'+i).value;
var rate1 = document.getElementById('rate'+i).value;
var result = parseFloat(qty1) * parseFloat(rate1);
if (!isNaN(result)) {
document.getElementById('sum'+i).value = result.toFixed(2);
}
sum_total();
}
function sum_total() {
var newTot = 0;
for (var a=0; a<=i ; a++) {
aVal = $('#sum'+a);
if (aVal && aVal.length) { newTot += aVal[0].value ? parseFloat(aVal[0].value) : 0; }
}
document.getElementById('allsum').value = newTot.toFixed(2);
}
</script>
<script>
$(document).ready(function() {
//this calculates values automatically
dueA();
$("#allsum, #pay").on("keydown keyup", function() {
dueA();
});
});
function dueA() {
var allsum = document.getElementById('allsum').value;
var pay = document.getElementById('pay').value;
var result = parseFloat(allsum)- parseFloat(pay);
if (!isNaN(result)) {
document.getElementById('dueA').value = result.toFixed(2);
}
}
</script>
Here is name.php.
<?php
require_once("config.php");
if (!isset($_SESSION["user_id"]) || $_SESSION["user_id"] == "") {
// not logged in send to login page
redirect("index.php");
}
$query = "INSERT INTO orders (date, party_name, party_address, party_ref, work_order_no, work_order_off, button_line, button_hole, button_type, logo_button, quantity, rate, amount, revised_rate, revised_amount, pro_in_no, pro_in_date, cash_bill_no, lc_sl_no, lc_no, lc_date, total_amount, pay_amount, due, mode, status) VALUES (:a, :b, :c, :d, :e, :f, :g, :h, :i, :j, :k, :l, :m, :n, :o, :p, :q, :r, :s, :t, :u, :v, :w, :x, :y, :z)";
for($count = 0; $count<count($_POST['qty']); $count++)
{
$data = array(
':a' => $_POST['date'],
':b' => $_POST['party_name'],
':c' => $_POST['party_address'],
':d' => $_POST['party_ref'],
':e' => $_POST['won'],
':f' => $_POST['woof'],
':g' => $_POST['button_line'][$count],
':h' => $_POST['button_hole'][$count],
':i' => $_POST['button_type'][$count],
':j' => $_POST['logo_button'][$count],
':k' => $_POST['qty'][$count],
':l' => $_POST['rate'][$count],
':m' => $_POST['total'][$count],
':n' => $_POST['r_rate'][$count],
':o' => $_POST['r_amount'][$count],
':p' => $_POST['pro_in_no'],
':q' => $_POST['pro_in_date'],
':r' => $_POST['cash_bill_no'],
':s' => $_POST['lc_sl_no'],
':t' => $_POST['lc_no'],
':u' => $_POST['lc_date'],
':v' => $_POST['total_amount'],
':w' => $_POST['pay_amount'],
':x' => $_POST['due'],
':y' => $_POST['mode'],
':z' => 'pending'
);
$statement = $DB->prepare($query);
$statement->execute($data);
}
header("location: orders.php");
?>
I am trying to insert data into the database and my code does add a new row but all the values are null. I don't know what's causing it. The view is inside a modal in html. Here's my code: Thanks for your help
Controller:
public function addItem(){
$save = array(
'inventoryID' => $this->input->post('rfid'),
'masterCode' => $this->input->post('masterCode'),
'itemName' => $this->input->post('itemName'),
'colorName' => $this->input->post('colorName'),
'location' => $this->input->post('location'),
'itemCategory' => $this->input->post('itemCategory'),
'materialDescription' => $this->input->post('materialDescription'),
'supplier' => $this->input->post('supplier'),
'itemDescription' => $this->input->post('itemDescription'),
'comments' => $this->input->post('comments'),
'itemCode' => $this->input->post('itemCode'),
'colorCode' => $this->input->post('colorCode')
);
$this->searchModel->form_insert($save);
//load the header
$this->load->view('base.php',$save);
//load the page
redirect('Search');
//load the footer
$this->load->view('footer.php',$save);
}
Model:
function form_insert($data){
// Inserting in Table(inventory) of Database(library)
$this->load->database();
$this->db->insert('inventory', $data);
$inventoryID = $this->db->insert_id();
}
View:
<div id="addItem" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<form method ="post" action= "<?php echo site_url("Search/addItem"); ?>">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Add an Item</h4>
</div>
<div class="modal-body">
<form role="form">
<table>
<tr>
<td><input type="text" name="rfid" placeholder="RFID" required/></td>
<td><input type="text" name="itemCode" placeholder="Item Code" required/></td>
<td><input type="text" name="masterCode" placeholder="Master Code" /></td>
</tr>
<tr>
<td><input type="text" name="itemName" placeholder="Item Name" required/></td>
<td><input type="text" name="colorCode" placeholder="Color Code" /></td>
<td><input type="text" name="colorName" placeholder="Color Name" /></td>
</tr>
<tr>
<td><input type="text" name="location" placeholder="Location" required/></td>
<td><input type="text" name="makelocation" placeholder="Location Made" required/></td>
<td><input type="text" name="itemCategory" placeholder="Item Category" /></td>
</tr>
<tr>
<td><input type="text" name="materialDescription" placeholder="Material Description" /></td>
<td><input type="text" name="supplier" placeholder="Supplier/Vendor" required/></td>
<td><input type="text" name="checkoutAllowed" placeholder="Checkout Allowed" /></td>
</tr>
</table>
<div class="row personal-info">
<div class="col-sm-4">
<div class="form-group">
<textarea name="itemDescription" placeholder="Insert information regarding the weather this item is suitable for and where it is used"></textarea>
<textarea name="Comments" placeholder="Additional Coments on the Item"></textarea>
</div>
</div>
</div>
</form>
</div>
<div class="modal-footer" style="text-align:center;">
<input class="btn btn-primary" name="addItem" value="Add Item">
</div>
</form>
</div>
</div>
</div>
The problem is that you do not actually "submit" the form data. Your button links to the correct controller/method but does not send any data to the controller when you use a link, i.e. <a href=.... You need a submit button.
The change is quite simple. Change the code for the button as follows.
<div class="modal-footer" style="text-align:center;">
<input type="submit" class="btn btn-primary" name="addItem" value="Add Item">
</div>
There is another issue. You have two <form> tags.
Remove the line
<form method ="post" action="<?php echo site_url("Search/addItem"); ?>">
And change the line
<form role="form">
to
<form method="post" action="<?php echo site_url("Search/addItem"); ?>" role="form">
You also need to remove the extra form close tag two lines above the button's code. Nested <form>s are not allowed. And you need to move the closing tag for <div class="modal-content"> So to make it more clear here is what your view should finally look like.
<div id="addItem" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Add an Item</h4>
</div>
<div class="modal-body">
<form method ="post" action= "<?php echo site_url("Search/addItem"); ?>" role="form">
<table>
<tr>
<td><input type="text" name="rfid" placeholder="RFID" required/></td>
<td><input type="text" name="itemCode" placeholder="Item Code" required/></td>
<td><input type="text" name="masterCode" placeholder="Master Code" /></td>
</tr>
<tr>
<td><input type="text" name="itemName" placeholder="Item Name" required/></td>
<td><input type="text" name="colorCode" placeholder="Color Code" /></td>
<td><input type="text" name="colorName" placeholder="Color Name" /></td>
</tr>
<tr>
<td><input type="text" name="location" placeholder="Location" required/></td>
<td><input type="text" name="makelocation" placeholder="Location Made" required/></td>
<td><input type="text" name="itemCategory" placeholder="Item Category" /></td>
</tr>
<tr>
<td><input type="text" name="materialDescription" placeholder="Material Description" /></td>
<td><input type="text" name="supplier" placeholder="Supplier/Vendor" required/></td>
<td><input type="text" name="checkoutAllowed" placeholder="Checkout Allowed" /></td>
</tr>
</table>
<div class="row personal-info">
<div class="col-sm-4">
<div class="form-group">
<textarea name="itemDescription" placeholder="Insert information regarding the weather this item is suitable for and where it is used"></textarea>
<textarea name="Comments" placeholder="Additional Coments on the Item"></textarea>
</div>
</div>
</div>
<div class="modal-footer" style="text-align:center;">
<input type="submit" class="btn btn-primary" name="addItem" value="Add Item">
</div>
</form>
</div>
</div>
</div>
</div>
Hi I have an error that says "Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 40 bytes)".
Basically, in the php file I extract the information that the user chooses to do a search with the function I created in a package in an ORACLE data base. In php I call the function, pass in the parameters and display all the results.
<?php
$db_connection = oci_connect('DBadmin', 'dbadmin', 'PETLOVERSDB');
if (!$db_connection) {
$e = oci_error();
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}
$type = $_GET['type'];
echo $type;
$result;
$resultArray;
$finalResult = ' ';
$sqlVariableFindMyPets = 'BEGIN :pet_variable := pet_search_package.pet_search_type(:p_type_data);END;';
$result = oci_new_cursor($db_connection);
$dataToReceive = oci_parse($db_connection, $sqlVariableFindMyPets);
oci_bind_by_name($dataToReceive, ':pet_variable', $result, -1, OCI_B_CURSOR);
oci_bind_by_name($dataToReceive, ':p_type_data', $type);
oci_execute($dataToReceive);
oci_execute($result, OCI_DEFAULT);
oci_fetch_all($result, $resultArray, null, null, OCI_FETCHSTATEMENT_BY_ROW);
oci_close($db_connection);
if($resultArray == null){
echo "<h2>No results found<h2>";
} else {
foreach($resultArray as $iterator){
$finalResult = $finalResult.'<div class="col-lg-4 col-sm-6">
<div class="properties">
<form action="pet-detail.php" method="POST">
<h4>'.$iterator['PET_TYPE_NAME'].' </h4>
<div class="image-holder"><img src="images/logo2.png" class="img-responsive" alt="properties"/></div>
<h5>'.$iterator['PET_RACE_NAME'].' </h5>
<h5>'.$iterator['PET_COLOR'].' </h5>
<h5>'.$iterator['PET_ENERGY_LEVEL'].'</h5>
<h5>'.$iterator['PET_COND_NAME'].'</h5>
<input class="form-control" type="text" style="display: none" readonly name="pet_code" value="'.$iterator['PET_CODE'].'"/>
<input class="form-control" type="text" style="display: none" readonly name="pet_name" value="'.$iterator['PET_NAME'].'"/>
<input class="form-control" type="text" style="display: none" readonly name="pet_type" value="'.$iterator['PET_TYPE_NAME'].'"/>
<input class="form-control" type="text" style="display: none" readonly name="pet_race" value="'.$iterator['PET_RACE_NAME'].'"/>
<input class="form-control" type="text" style="display: none" readonly name="pet_cond" value="'.$iterator['PET_COND_NAME'].'"/>
<input class="form-control" type="text" style="display: none" readonly name="pet_energy" value="'.$iterator['PET_ENERGY_LEVEL'].'"/>
<input class="form-control" type="text" style="display: none" readonly name="pet_learn" value="'.$iterator['PET_LEARN_SKILL'].'"/>
<input class="form-control" type="text" style="display: none" readonly name="pet_vet" value="'.$iterator['VET_NAME'].'"/>
<input class="form-control" type="text" style="display: none" readonly name="pet_p_name" value="'.$iterator['PERSON_NAME'].'"/>
<input class="form-control" type="text" style="display: none" readonly name="pet_location" value="'.$iterator['PETLOCATION'].'"/>
<input class="form-control" type="text" style="display: none" readonly name="pet_notes" value="'.$iterator['PETNOTES'].'"/>
<input class="form-control" type="text" style="display: none" readonly name="pet_space" value="'.$iterator['PET_SPACE'].'"/>
<input class="form-control" type="text" style="display: none" readonly name="pet_treatment" value="'.$iterator['PET_TREATMENT'].'"/>
<input class="form-control" type="text" style="display: none" readonly name="pet_color" value="'.$iterator['PET_COLOR'].'"/>
<input class="form-control" type="text" style="display: none" readonly name="pet_sickness" value="'.$iterator['PET_SICKNESS_NAME'].'"/>
<input class="form-control" type="text" style="display: none" readonly name="pet_med" value="'.$iterator['PET_MED_NAME'].'"/>
<input type="submit" class="btn btn-primary" value="View Details" />
</form>
</div>
</div>';
}
echo $finalResult;
}
?>
And the function in ORACLE is
CREATE OR REPLACE PACKAGE BODY pet_search_package AS
FUNCTION pet_search_type(TYPEPET in VARCHAR2)
RETURN SYS_REFCURSOR
IS
pet_search_result SYS_REFCURSOR;
type_id NUMBER;
BEGIN
select TP.pet_type_code into type_id
from dbadmin.petType TP
where TP.pet_type_name = TYPEPET;
OPEN pet_search_result FOR select pet_type_name, pet_race_name, pet_cond_name, pet_energy_level, pet_learn_skill, vet_name, person_name, petlocation, petnotes, petabandondescription, pet_space, pet_treatment, pet_color, pet_sickness_name, pet_med_name
from pet, pettype, petrace, petCondition, petSize,petEnergy, petlearningskill, veterinary, person, petSpace, pettreatments, petcolor, petsickness, petmedicine
WHERE pettype.pet_type_code = type_id;
RETURN pet_search_result;
EXCEPTION
WHEN NO_DATA_FOUND THEN
RETURN null;
END;
END pet_search_package;
I have tried putting ini_set('memory_limit', '-1'); on the php file but it doesn't seem to work. I also read that I have to increase variables ? which variables and where ? What can I do to solve this problem? Im not sure what is going on. Please, any suggestions would be appreciated !
PS. I tried the function on the database and works just fine
My guess is that you have a large table and your program fails while preparing the output.
instead of doing :
foreach($resultArray as $iterator){
$finalResult = $finalResult.'<div class="col-lg-4 col-sm-6">
<div class="properties">
<form action="pet-detail.php" method="POST">
<h4>'.$iterator['PET_TYPE_NAME'].' </h4>
<div class="image-holder"><img src="images/logo2.png" class="img-responsive" alt="properties"/></div>
<h5>'.$iterator['PET_RACE_NAME'].' </h5>
<h5>'.$iterator['PET_COLOR'].' </h5>
<h5>'.$iterator['PET_ENERGY_LEVEL'].'</h5>
<h5>'.$iterator['PET_COND_NAME'].'</h5>
<input class="form-control" type="text" style="display: none" readonly name="pet_code" value="'.$iterator['PET_CODE'].'"/>
<input class="form-control" type="text" style="display: none" readonly name="pet_name" value="'.$iterator['PET_NAME'].'"/>
<input class="form-control" type="text" style="display: none" readonly name="pet_type" value="'.$iterator['PET_TYPE_NAME'].'"/>
<input class="form-control" type="text" style="display: none" readonly name="pet_race" value="'.$iterator['PET_RACE_NAME'].'"/>
<input class="form-control" type="text" style="display: none" readonly name="pet_cond" value="'.$iterator['PET_COND_NAME'].'"/>
<input class="form-control" type="text" style="display: none" readonly name="pet_energy" value="'.$iterator['PET_ENERGY_LEVEL'].'"/>
<input class="form-control" type="text" style="display: none" readonly name="pet_learn" value="'.$iterator['PET_LEARN_SKILL'].'"/>
<input class="form-control" type="text" style="display: none" readonly name="pet_vet" value="'.$iterator['VET_NAME'].'"/>
<input class="form-control" type="text" style="display: none" readonly name="pet_p_name" value="'.$iterator['PERSON_NAME'].'"/>
<input class="form-control" type="text" style="display: none" readonly name="pet_location" value="'.$iterator['PETLOCATION'].'"/>
<input class="form-control" type="text" style="display: none" readonly name="pet_notes" value="'.$iterator['PETNOTES'].'"/>
<input class="form-control" type="text" style="display: none" readonly name="pet_space" value="'.$iterator['PET_SPACE'].'"/>
<input class="form-control" type="text" style="display: none" readonly name="pet_treatment" value="'.$iterator['PET_TREATMENT'].'"/>
<input class="form-control" type="text" style="display: none" readonly name="pet_color" value="'.$iterator['PET_COLOR'].'"/>
<input class="form-control" type="text" style="display: none" readonly name="pet_sickness" value="'.$iterator['PET_SICKNESS_NAME'].'"/>
<input class="form-control" type="text" style="display: none" readonly name="pet_med" value="'.$iterator['PET_MED_NAME'].'"/>
<input type="submit" class="btn btn-primary" value="View Details" />
</form>
</div>
</div>';
}
echo $finalResult;
try this foreach loop:
foreach($resultArray as $iterator){
echo '<div class="col-lg-4 col-sm-6">
<div class="properties">
<form action="pet-detail.php" method="POST">
<h4>'.$iterator['PET_TYPE_NAME'].' </h4>
<div class="image-holder"><img src="images/logo2.png" class="img-responsive" alt="properties"/></div>
<h5>'.$iterator['PET_RACE_NAME'].' </h5>
<h5>'.$iterator['PET_COLOR'].' </h5>
<h5>'.$iterator['PET_ENERGY_LEVEL'].'</h5>
<h5>'.$iterator['PET_COND_NAME'].'</h5>
<input class="form-control" type="text" style="display: none" readonly name="pet_code" value="'.$iterator['PET_CODE'].'"/>
<input class="form-control" type="text" style="display: none" readonly name="pet_name" value="'.$iterator['PET_NAME'].'"/>
<input class="form-control" type="text" style="display: none" readonly name="pet_type" value="'.$iterator['PET_TYPE_NAME'].'"/>
<input class="form-control" type="text" style="display: none" readonly name="pet_race" value="'.$iterator['PET_RACE_NAME'].'"/>
<input class="form-control" type="text" style="display: none" readonly name="pet_cond" value="'.$iterator['PET_COND_NAME'].'"/>
<input class="form-control" type="text" style="display: none" readonly name="pet_energy" value="'.$iterator['PET_ENERGY_LEVEL'].'"/>
<input class="form-control" type="text" style="display: none" readonly name="pet_learn" value="'.$iterator['PET_LEARN_SKILL'].'"/>
<input class="form-control" type="text" style="display: none" readonly name="pet_vet" value="'.$iterator['VET_NAME'].'"/>
<input class="form-control" type="text" style="display: none" readonly name="pet_p_name" value="'.$iterator['PERSON_NAME'].'"/>
<input class="form-control" type="text" style="display: none" readonly name="pet_location" value="'.$iterator['PETLOCATION'].'"/>
<input class="form-control" type="text" style="display: none" readonly name="pet_notes" value="'.$iterator['PETNOTES'].'"/>
<input class="form-control" type="text" style="display: none" readonly name="pet_space" value="'.$iterator['PET_SPACE'].'"/>
<input class="form-control" type="text" style="display: none" readonly name="pet_treatment" value="'.$iterator['PET_TREATMENT'].'"/>
<input class="form-control" type="text" style="display: none" readonly name="pet_color" value="'.$iterator['PET_COLOR'].'"/>
<input class="form-control" type="text" style="display: none" readonly name="pet_sickness" value="'.$iterator['PET_SICKNESS_NAME'].'"/>
<input class="form-control" type="text" style="display: none" readonly name="pet_med" value="'.$iterator['PET_MED_NAME'].'"/>
<input type="submit" class="btn btn-primary" value="View Details" />
</form>
</div>
</div>';
}
So just display the results as you iterate through them. Your code will have a more efficient use of memory.