Saving multiple table rows at once (Laravel 4) - php

I have a table where I get the data from database than i need to update all rows at once. Inside each cell I have added input fields. Now i want to be able to update all users at once when I enter the data but I dont know how.
Below is a picture of my view:
#extends('admin/master')
#section('content')
<section class="content">
{{Form::open()}}
<div class="row">
<div class="col-xs-12">
<div class="box">
<div class="box-header">
<div class="col-lg-4">
<h3 class="box-title">INPUT EXAM RESULTS FOR EACH STUDENT: </h3>
</div>
<div class="pull-right col-lg-8">
<div class="col-lg-2 col-lg-offset-5 pull-left">
<select class="btn bg-navy" name="city" >
<option>Select City</option>
<option>Prishtin</option>
<option>Prizren</option>
</select>
</div>
<div class="col-lg-5 pull-right">
<div class="input-group">
<input type="text" name="search_input" class="form-control" placeholder="Search here...">
<div class="input-group-btn">
<button type="submit" class="btn btn-info"><i class="fa fa-search"></i> Search</button>
</div>
</div>
</div>
</div>
</div>
<div class="box-body">
<?php if (isset($data)) { ?>
<table id="example2" class="table table-bordered table-hover">
<thead>
<tr>
<th>{{Lang::get('messages.stid')}} </th>
<th>{{Lang::get('messages.name')}}</th>
<th>Subject 1</th>
<th>Subject 2</th>
<th>Subject 3</th>
<th>Subject 4</th>
</tr>
</thead>
<tbody>#foreach ($data as $row)
<tr>
<td>{{$row->id}}</td>
<td>{{$row->fname}} {{$row->lname}}</td>
<td><input type="text" name="sub1" class="form-control" placeholder="Add marks here..."></td>
<td><input type="text" name="sub2" class="form-control" placeholder="Add marks here..."></td>
<td><input type="text" name="sub3" class="form-control" placeholder="Add marks here..."></td>
<td><input type="text" name="sub4" class="form-control" placeholder="Add marks here..."></td>
</tr>
#endforeach
</tbody>
</table>
<button type="submit" class="col-lg-2 pull-right btn btn-success"><i class="fa fa-save"></i> Save</button>
<?php } ?>
</div>
</div>
</div>
</div>
{{Form::close()}}
</section>
{{ HTML::script('/admin/assets/js/jquery-2.2.3.min.js') }}
{{ HTML::script('/admin/assets/js/bootstrap.min.js') }}
{{ HTML::script('/admin/assets/js/jquery.dataTables.min.js') }}
{{ HTML::script('/admin/assets/js/dataTables.bootstrap.min.js') }}
<script>
$(function () {
$("#example1").DataTable();
$('#example2').DataTable({
"paging": true,
"lengthChange": false,
"searching": false,
"ordering": true,
"info": true,
"autoWidth": false
});
});
</script>
#stop
//Controller
public function search_input(){
$input = Input::get('search_input');
$city = Input::get('city');
$data = Apply::where('exam_venue', '=', "$input")
->where('city_applied', '=', "$city")->get();
if (isset($_POST['save'])) {
}
return View::make('admin/exam/edit',compact('data'));
}

Your input elements need to be arrays, keyed by $row->id (I assume this is the primary key of your students table) to identify which student that row represents. For example:
<td><input type="text" name="sub1[{{ $row->id}}]" class="form-control" placeholder="Add marks here..."></td>
Then when you submit the data, look up the student by the array key and update their information accordingly. Something to the effect of:
$key = // extract id from sub1 array
Student::find($request->input($key));
// do updates here
// repeat for each sub input...

Related

How to select specific columns and get data from those columns and store them in different columns in another table? (Laravel)

hope you all are doing well. I have two tables in my database purchase__request and purchase_order. So what I was trying to do is get the data from the columns item_name, description, item_qty, and dep_name whose status ='Approved' from the purchase__request table. And then store them in the purchase_order table with column names as follows: item_name, description, item_qty, dep_name; and still be able to fill in the other columns in this (purchase_order) table.
So when I use the following code below it shows me this Error:
Attempt to assign property "[{"item_name":"Paper","description":"A4
size","item_qty":15,"dep_name":"Accounting &
Finance"},{"item_name":"d","description":"a","item_qty":4,"dep_name":"Accounting
& Finance"}]" on null
PO.blade.php:
<form action="{{url('/addPO')}}" method="POST">
#csrf
<div class="form-group row">
<label class="col-lg-4 col-form-label" for="po_date">Order Date <span class="text-danger">*</span> </label>
<div class="col-lg-6">
<input type="date" class="po_date" id="po_date" name="po_date" required="" />
</div>
</div>
<br />
<div class="table-responsive">
<table class="table text-start align-middle table-bordered table-hover mb-0">
<thead>
<tr class="text-dark">
<th scope="col">PR ID</th>
<th scope="col">Item Name</th>
<th scope="col">Description</th>
<th scope="col">Quantity</th>
<th scope="col">Department</th>
</tr>
</thead>
#foreach($PO as $PO)
<tbody>
<tr>
<td><input type="text" value="{{$PO->PR_id}}" hidden="" />{{$PO->PR_id}}</td>
<td><input type="text" value="{{$PO->item_name}}" hidden="" />{{$PO->item_name}}</td>
<td><input type="text" value="{{$PO->item_name}}" hidden="" />{{$PO->description}}</td>
<td><input type="text" value="{{$PO->item_qty}}" hidden="" />{{$PO->item_qty}}</td>
<td><input type="text" value="{{$PO->dep_name}}" hidden="" />{{$PO->dep_name}}</td>
</tr>
</tbody>
#endforeach
</table>
</div>
<br />
<br />
<div class="form-group row">
<label class="col-lg-4 col-form-label" for="sum">Sum<span class="text-danger">*</span></label>
<div class="col-lg-6">
<input type="number" class="sum" id="sum" name="sum" required="" />
</div>
</div>
<div class="form-group row">
<label class="col-lg-4 col-form-label" for="vat">Vat<span class="text-danger">*</span></label>
<div class="col-lg-6">
<input type="number" class="vat" id="vat" name="vat" required="" />
</div>
</div>
<div class="form-group row">
<label class="col-lg-4 col-form-label" for="approved_by">Approved By<span class="text-danger">*</span> </label>
<div class="col-lg-6">
<input type="text" class="approved_by" id="approved_by" name="approved_by" required="" />
</div>
</div>
<br />
<br />
<div class="form-group row">
<div class="">
<input type="submit" class="btn btn-success" name="submit" value="Submit" />
</div>
</div>
</form>
Routes:
Route:: view('addPO', 'admin.PO');
Route::post('/addPO', [AdminController::class, 'addDataOrder']);
My function in AdminController:
public function addDataOrder(Request $request)
{
$PO = new purchase_order();
$PO->po_date = $request->po_date ;
$PO->sum = $request->sum ;
$PO->vat = $request->vat;
$PO->approved_by = $request->approved_by ;
$PO = DB::table("purchase__requests")->select('item_name','description','item_qty','dep_name')->where('status', 'Approved')->get();
foreach($PO as $key->$PO){
DB::table("purchase_order")->insert(
[
'item_name' => $PO->item_name,
'description' => $PO->description,
'item_qty ' => $PO->item_qty,
'dep_name ' => $PO->dep_name,
]);
}
$PO->save();
return redirect()->back();
}
Please help me I'm new to Laravel.
Laravel uses Models as associations with database tables. You can read more here - https://laravel.com/docs/9.x/eloquent#introduction. Bookmark the Laravel docs, they are very useful.
From what I can see so far, you will need two new models - PurchaseRequest and PurchaseOrder
As in Laravel's docs, you can create a model with the artisan command:
php artisan make:model PurchaseRequest
Also, your purchase__requests table should be renamed to purchase_requests (single underline instead of two).
You really need to read at least some of the Laravel docs to be productive with Laravel. I hope you take your time to at least read the link I've sent you.
Anyway, after you create your models, you could then save the purchase order this way:
$purchaseOrder = new PurchaseOrder();
$purchaseOrder->po_date = $request->po_date;
$purchaseOrder->sum = $request->sum;
// and so on for other fields, then we save the model and this will write the data to the database
$purchaseOrder->save();
You should also do some validation for the $request variable to make sure that you don't save invalid stuff, such as the po_date being a thousand years in the past, etc. You can read more about how to do validation with Laravel here - https://laravel.com/docs/9.x/validation#main-content

foreach() argument must be of type array|object, null given in laravel 8

I am trying to insert data by Select users from checkbox's and input different point for each user
but when I submit I got this error
and is that the correct way to insert multi value coming from checkboxes in the model
with different point for each user
Can someone please help me to find out Where I am wrong?
<form method="post" action="{{route('user.action.push')}}" >
#csrf
<table class="display table table-bordered table-separated" >
<thead>
<th scope="row">
<label class="custom-control custom-checkbox">
<input id="selectAll" class="custom-control-input" type="checkbox">
<span class="custom-control-label"></span>
<span style="background-color:red;" class="custom-control-description sr-only"></span>
</label>
</th>
<th>Name</th>
<th>Email</th>
<th>point</th>
</tr>
</thead>
<tbody>
#foreach($users as $user)
<tr>
<td scope="row">
<label class="custom-control custom-checkbox">
<input type="checkbox" name="user_[{{$user->id}}]" value="{{$user->id}}" class="custom-control-input" >
<span class="custom-control-label"></span>
<span style="background-color:red;" class="custom-control-description sr-only"></span>
</label>
</td>
<td style="color:white">{{$user->name}}</td>
<td style="color:white">{{$user->email}}</td>
<td style="color:white"><input type="text" name="point_[{{$user->id}}]" >
</td>
</tr>
#endforeach
</tbody>
<tfoot>
<tr>
<th>Select</th>
<th>Name</th>
<th>Email</th>
<th>point</th>
</tr>
</tfoot>
</table>
</div>
</div>
<!-- /.box-body -->
</div>
<!-- /.box -->
</div>
<div class="col-3">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">Select Action</h3>
</div>
<!-- /.box-header -->
<div class="box-body">
<div class="form-group">
<h5>Select Action <span class="text-danger">*</span></h5>
<div class="controls">
<select name="action_id" class="form-control" >
<option disabled="" selected="">Select Action</option>
#foreach($actions as $action)
<option value="{{$action->id}}">{{$action->action_title}}</option>
#endforeach
</select>
<br>
<button type="submit" class="btn btn-rounded btn-primary"> send</button>
</form>
the ActionUserPush function
public function ActionUserPush(Request $request){
foreach($request->user_id as $user_id){
$point = $request->point_[$user_id];
ActionUser::insert([
'user_id'=>$user_id,
'point' =>$point,
'action_id'=>$request->action_id,
]); }
$notification = array(
'message' => ' Action Activited Successfully',
'alert-type' => 'success'
);
return redirect()->route('user_action_view')->with($notification);}
You don't have any input with nameuser_idand in your form you can not define the input name dynamically like you have done. You should have to use a fixed name for it. Change your form input to:
<input type="checkbox" name="user_id[]" value="{{$user->id}}" class="custom-control-input" >
Then you can access it by using $request->user_id
You have to use like below
name="user_id[]"
You don't have any input with nameuser_idand in your form you can not define the input name dynamically like you have done. You should have to use a fixed name for it. Change your form input to:
id}}" class="custom-control-input" >
Then you can access it by using $request->user_id

laravel 4 download file from different folders

Hi Guys i just need some help on my download page in my project because i need to have a download page that get files from different folders all of the folder is in the public path do you have some ideas for this i am using a page just like the link below just ignore the other button.
Download Page
i just tried ajax for this but it doesn't work
this my view:
#include('partials.navbar')
<link rel="stylesheet" type="text/css" href="http://localhost:8000/assets/css/jquery.dataTables.min.css">
<link rel="stylesheet" type="text/css" href="http://localhost:8000/assets/css/search.css">
<!-- Search -->
<div class="container">
<!-- Search -->
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="input-group" id="adv-search">
<input type="text" class="form-control" placeholder="Search file" />
<div class="input-group-btn">
<div class="btn-group" role="group">
<div class="dropdown dropdown-lg">
<button type="button" class="set-width btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false"><span class="caret"></span></button>
<div class="dropdown-menu dropdown-menu-right" role="menu">
<form class="form-horizontal" role="form">
<div class="form-group">
<label for="file">File type</label>
<select class="form-control">
<option value="pf">Public Weather Forecast</option>
<option value="sf">24 Shipping Forecast</option>
<option value="gale">Gale Warning Forecast</option>
<option value="advisory">Weather Advisory</option>
<option value="tca">Tropical Cyclone Advisory</option>
<option value="swb">Severe Weather Bulletin</option>
<option value="iws">International Warning for shipping</option>
<option value="wof">Weather Outlook Forecast</option>
<option value="spf">Special Forecast</option>
<option value="sm">Surface Maps</option>
</select>
</div>
<div class="form-group">
<label for="date">Date</label>
<input class="form-control" type="date" />
</div>
<div class="form-group">
<label for="file">File name</label>
<input class="form-control" type="text" />
</div>
<button type="submit" class="btn btn-primary"><i class="fa fa-search"></i></button>
</form>
</div>
</div>
<button type="button" class="btn btn-primary"><i class="fa fa-search"></i></button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!--- Datatable -->
<div class="container">
<div class="row">
<div class="col-md-12">
<h4>Downloads</h4>
<table id="mytable" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>File Name</th>
<th>Date Issued</th>
<th>File ID Number</th>
<th>Uploader</th>
<th>Action</th>
</tr>
</thead>
<tfoot>
<tr>
<th>File Name</th>
<th>Date Issued</th>
<th>File ID Number</th>
<th>Uploader</th>
<th>Action</th>
</tr>
</tfoot>
<tbody>
#foreach ($files as $files2)
<tr>
<td>{{ $files2->file_name }}</td>
<td>{{ $files2->date }}</td>
<td>{{ $files2->id }}</td>
<td>{{ $files2->username }}</td>
<td><a data-id="{{ $files2->id }}" href="/download" class="btn btn-primary btn-xs dload-button" ><i class="fa fa-download"></i></a>
<button data-id="" class="btn btn-primary btn-xs dload-button" data-title="Dload" data-toggle="modal" data-target="#dload-modal"><i class="fa fa-file-text"></i></button></td>
</tr>
#endforeach
</tbody>
</table>
<input type="hidden" name="id" value="">
<input type="hidden" name="type" value="">
<input type="hidden" name="filename" value="">
</div>
</div>
</div>
</div>
#include('partials.footer')
<script type="text/javascript" src="http://localhost:8000/assets/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="http://localhost:8000/assets/js/dropdown.js"></script>
<script type="text/javascript" src="http://localhost:8000/assets/js/datatable.js"></script>
<script>
$(function() {
$(".dload-button").click(function(){
var param = $(this).data('id');
$.ajax({
url: "/downloadfile/" + param,
success: function(msg){
var dload = JSON.parse(msg)[0];
console.log(dload)
$('#id').val(dload.id);
$('#type').val(dload.file_type);
$('#filename').val(dload.upload);
},
error:function(){
alert("failure");
}
});
});
});
my controller:
public function dloadFile($id)
{
$files = Files::where('id',$id)
->get();
return json_encode($files);
}
public function getDownload()
{
$id = Input::get('id');
$files = Files::where('id',$id)
->first();
$ftype = $files->file_type = Input::get('type');
$filename = $files->upload = Input::file('filename');
$file= public_path(). "uploads/{$ftype}";
$headers = array(
'Content-Type: => application/pdf',
);
return Response::download($file, '{$filename}', $headers);
}
my route:
Route::get('/downloadfile/{id}', 'FileController#dloadFile');
Route::get('/download', array('uses' => 'FileController#getDownload'));
Any idea is much more appreciated Thanks in advance!.
there is no need to use Ajax for download. there is my code to download product image.in view file there is download link.
<a data-id="{{ $product->id }}" href="/productCRUD/{{$product->id}}/download" class="btn btn-primary btn-xs dload-button" ><i class="fa fa-download">Download</i></a>
in routes.php
Route::get('productCRUD/{product}/download', 'ProductCRUDController#download');
in productCRUDController.php
public function download($id)
{
$files = Product::where('id',$id)
->first();
$ftype = $files->file_type = Input::get('type');
$fullPath= public_path(). "/uploads/{$files->filePath}";
$headers = array(
'Content-Type: => application/jpg',
);
return Response::download($fullPath,$files->filePath, $headers);
}
with this code when you click on download link you get the file in your downloads folder.

Clone Table Row With PHP Data Select Box

I am newbie in php as well as bootstrap. I am trying to create master-detail form to receive product from supplier. I had somehow manage to build the format but have difficulties on cloning table row with php select box. My HTML codes are below ...
<div class="form-group">
<div class='row'>
<div class='col-xs-1 col-sm-1 col-md-1 col-lg-1'> </div>
<div class='col-xs-10 col-sm-10 col-md-10 col-lg-10'>
<table class="table table-bordered table-hover" id="table-data">
<thead>
<tr>
<th width="2%"><input id="check_all" class="formcontrol" type="checkbox"/></th>
<th width="38%">Parts Name</th>
<th width="15%">Price</th>
<th width="15%">Quantity</th>
<th width="15%">Total</th>
</tr>
</thead>
<tbody>
<tr id="id1" class="tr_clone">
<td><input class="case" type="checkbox"/></td>
<td>
<div class="dropdown">
<select data-type="partsCode" name="partsNo[]" id="partsNo1" class="form-control">
<?php
$query = "SELECT PARTS_ID, PARTS_NAME FROM parts_info ORDER BY PARTS_NAME";
if ($result = mysqli_query($con, $query))
{
while ($row = mysqli_fetch_array($result))
{
?>
<option value=<?php echo $row['PARTS_ID']; if ($shopid == $row['PARTS_ID']) echo " selected"; ?>> <?php echo $row['PARTS_NAME']; ?> </option>
<?php
}
}
mysqli_free_result($result);
?>
</select>
</div>
</td>
<td><input type="number" name="price[]" id="price1" class="form-control changesNo" onkeypress="return IsNumeric(event);" ondrop="return false;" onpaste="return false;"></td>
<td><input type="number" name="quantity[]" id="quantity1" class="form-control changesNo" onkeypress="return IsNumeric(event);" ondrop="return false;" onpaste="return false;"></td>
<td><input type="number" name="total[]" id="total1" class="form-control totalLinePrice" onkeypress="return IsNumeric(event);" ondrop="return false;" onpaste="return false;"></td>
</tr>
</tbody>
</table>
</div>
<div class='col-xs-1 col-sm-1 col-md-1 col-lg-1'> </div>
</div>
<div class='row'>
<div class='col-xs-1 col-sm-1 col-md-1 col-lg-1'> </div>
<div class='col-xs-12 col-sm-3 col-md-3 col-lg-3'>
<button class="btn btn-danger" type="button">- Delete</button>
<button class="btn btn-success" type="button">+ Add More</button>
</div>
<div class='col-md-3 col-md-offset-4'>
<button class="btn btn-primary btn-block" id="button" type="submit" name="submit" value="Submit">Save</button>
</div>
<div class='col-xs-1 col-sm-1 col-md-1 col-lg-1'> </div>
</div>
</div>
Please anyone can solve my issue will be greatfull. I need to dynamically Add and Remove Row with this two buttons.
Also if anyone have any reference on how to make master-detail form in php with bootstrap will support me well. Thank you in Advance.
To get a concept please check the following URL. I want to add Parts Name to Total as a new row when I press + Add More. Please note that the Parts Name comes from MySQL through PHP code ...
jsfiddle.net/imranctgbd/34djbLLn
Hi would have been helpful if there was a screenshot so i can fully understand your question. But here's what i fink you want to do.
to the cell holding ur delete checkbox, add , this means u have to create a delete.php and link it properly.
<td> <a href='delete.php?id=$id' class='button small blue'>Delete</a> </td>
then here's what you do in your delete page
request id or whatever you want from your table and run a query. see example beneath
<?php
require_once('core.php');
$id = $_REQUEST['id'];
$sql = "delete from bookings where id = '$id'";
$result = mysqli_query($conn,$sql);
if ($result){
$count = mysqli_affected_rows($conn);
if($count > 0){
$redirect = header('location:index.php');
echo $redirect;
}
}
?>
same principle can be applied for addition or you could just use javascript for that dynamically...

Submit INPUT to the database to return as a Table PHP jQuery MySQL

I'm trying to refresh a data input into an INPUT through a form and then SUBMIT this to the database to return it as a table on the same page. I want it to do this without showing the refresh of the page.
This is what I have currently. When I put data into any of the INPUT fields and click SUBMIT nothing happens and nothing shows for an error.
<?php
session_start();
error_reporting (E_ALL);
require '../core/cnn.php';
if(isset($_POST['submitsearchprojno'])) {
$searchprojno = $_POST["searchprojno"];
}
if(isset($_POST['submitsearchadd'])) {
$searchaddress = $_POST["searchaddress"];
}
if(isset($_POST['submitsearchpc'])) {
$searchpostcode = $_POST["searchpostcode"];
}
$searchpostcode = mysql_real_escape_string($searchpostcode);
$searchaddress = mysql_real_escape_string($searchaddress);
$searchprojno = mysql_real_escape_string($searchprojno);
?>
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
<h4 class="modal-title">Search Projects</h4>
</div>
<div class="modal-body">
<form class="modal-form" id="searchform" name="searchform" action="" method="post">
<div class="form-group">
<label class="col-md-4 control-label">Project Number</label>
<div class="col-md-6">
<input type="text" class="form-control input-inline input-medium" name="searchprojno" id="searchprojno" placeholder="Enter Project Number">
</div>
<button type="submit" class="btn blue" id="submitsearchprojno" name="submitsearchprojno" >Search <i class="m-icon-swapright m-icon-white"></i></button>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Address</label>
<div class="col-md-6">
<input type="text" class="form-control input-inline input-medium" name="searchaddress" id="searchaddress" placeholder="Enter Address">
</div>
<button type="submit" class="btn blue" id="submitsearchadd" name="submitsearchadd" >Search <i class="m-icon-swapright m-icon-white"></i></button>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Postcode</label>
<div class="col-md-6">
<input type="text" class="form-control input-inline input-medium" name="searchpostcode" id="searchpostcode" placeholder="Enter Postcode">
</div>
<button type="submit" class="btn blue" id="submitsearchpc" name="submitsearchpc" >Search <i class="m-icon-swapright m-icon-white"></i></button>
</div>
<div class="form-group">
<div class="col-md-12">
<div class="table-responsive">
<table class="table table-striped table-bordered table-advance table-hover">
<thead>
<tr>
<th class="col-md-9"><i class="fa fa-list-alt"></i> Address</th>
<th class="col-md-3"></th>
</tr>
</thead>
<tbody>
<tr>
<?php $searchrs = mysql_query("SELECT ProjectNo, CONCAT(COALESCE(HouseNoName, ''), ' ', COALESCE(StreetName, ''), ' ',
COALESCE(TownOrCity, ''), ' ', COALESCE(Postcode, '')) AS Display, PropID, AreaID, AWGMember, Householder, HouseNoName,
StreetName, TownOrCity, Postcode, ContactTelephone, AlternatePhone, Email, PropertyTenure, PropertyNotes
FROM prop_property
WHERE IsActive = 1
AND (Postcode = '".$searchpostcode."'
OR StreetName = '".$searchaddress."'
OR ProjectNo = '".$searchprojno."')
") or die(mysql_error());
$checkrs = mysql_query("SELECT * FROM prop_property WHERE IsActive = 0");
if(!mysql_num_rows($checkrs) > 0) {
echo '<td> No record found!</td><td></td>';
}
else {
while ($results = mysql_fetch_array($searchrs)) {
echo '
<td id="displayadd">'.$results['Display'].'</td>
<td>
<form action="../jobdetails.php" method="post">
<input type="hidden" name="searchhouse" value=" '.$results['HouseNoName'].'" >
<input type="hidden" name="searchstreet" value=" '.$results['StreetName'].'" >
<input type="hidden" name="searchtown" value=" '.$results['TownOrCity'].'" >
<input type="hidden" name="searchpostcode" value=" '.$results['Postcode'].'" >
<input type="hidden" name="searchpropid" value=" '.$results['PropID'].'" >
<input type="hidden" name="searchprojectno" value=" '.$results['ProjectNo'].'" >
<button type="submit" class="btn default btn-xs blue-stripe" id="viewsearch" name="viewsearch">View Address</button>
</form>
</td>';
}
}?>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</form>
<div class="modal-footer right">
<button type="button" data-dismiss="modal" class="btn default">Cancel</button>
</div>
<script type="text/javascript">
$(function(){
$('#searchform').on('submit', function(e){
e.preventDefault();
//alert($('#searchpostcode').val())
$.post('includes/jobdetailssearch.php',
$('#searchform').serialize(),
function(data, status){
$('.table-responsive #displayadd').html(data.Display);
//$("#table-responsive td").last().append(data);
console.log("done");
}).fail(function () {
console.log("fail");
});
});
});
</script>
How can I get it to POST the INPUT to the database and return in the table?

Categories