Link to home
Start Free TrialLog in
Avatar of mani gopal
mani gopal

asked on

Need to get datas from DB? when i enter the id !

I am in development of Delivery Challan Module., @ which i got struck is

when i enter my invoice_no(in textbox) it should fetch datas from db and displays. This is what i was looking for.,
whereas in this i use two tables invoiceinfo & invoice_details

i have already got infos from invoiceinfo(table) which means when i enter the invoice_no it will fetch some details such like customer details etc.,

but @invoice_details alone i cant get details.,

actually i had interconnected both  invoiceinfo & invoice_details for delete & update purposes!

I used this code but doesnt works


$select_productdetail_query = "SELECT * FROM invoice_details WHERE invoiceinfo_id='".$_REQUEST['invoice_no']."'";

$productdetail_query_result = mysqli_query($connection, $select_productdetail_query);      

while($productdetailview = mysqli_fetch_array($productdetail_query_result)){
<?php //echo $productdetailview['product_code']; ?>
                                                 <td><strong><small><?php echo $productdetailview['product_code']; ?></strong></small> </td>
                                 <td style="text-align:left;"><strong><small><?php echo $productdetailview['product_name']; ?></strong></small></td>
                                                 <td><strong><small><?php echo $productdetailview['product_quantity']; ?></strong></small></td>
                                                 <td><strong><small><?php echo $productdetailview['product_price']; ?></strong></small></td>
                                 <td><strong><small><?php echo $productdetailview['total_price']; ?></strong></small></td>
                                                 
                            </tr>
                                          <?php } ?>
autosuggest_invoicedetails.php
delivery_challan_add.php
delivery_challan_save.php
Avatar of Leonidas Dosas
Leonidas Dosas
Flag of Greece image

What error do you have when debugging the code?
Could you posy what you get with

echo var_dump($productdetailview);

Open in new window

Avatar of mani gopal
mani gopal

ASKER

Notice: Undefined index: invoice_no in C:\xampp\htdocs\billing_application\pages\delivery_challan_add.php on line 449

I got this error when i run this code
Notice: Undefined variable: productdetailview in C:\xampp\htdocs\billing_application\pages\delivery_challan_add.php on line 445
NULL

Notice: Undefined index: invoice_no in C:\xampp\htdocs\billing_application\pages\delivery_challan_add.php on line 449
There's a LOT of code going on there. You say the error is on line 445 / 449, but in the code you've posted there are several lines commented out. There are 2 that refer to invoice_no. You're trying to get it from either the POST array or the REQUEST array, and it doesn't exist. Check the form that posts to this script to make sure you are indeed sending the invoice_no.
when i assign a variable using the POST method @startup of the page. It shows error too.,
all need is using select query that too be fetched from one table using invoice_no. whereas there is  a textbox
once i enter value @that textbox it should the data.,


$select_productdetail_query = "SELECT * FROM invoice_details WHERE invoiceinfo_id='".$_REQUEST['invoice_no']."'"; - this resembles the code

$_REQUEST['invoice_no'] @ this it should be taken from a textbox input @which i have already given
If that were the case, then you wouldn't be getting the Undefined index: invoice_no error. That error means that the array does not contain an invoice_no key.

Before you try to build the query, add in the following line:

var_dump($_REQUEST);

That will show you exactly what info was sent to the page. Examine that and you'll see that the invoice_no key is not in there.
this is the error :


array(0) { }
Notice: Undefined variable: productdetailview in C:\xampp\htdocs\billing_application\pages\delivery_challan_add.php on line 446
NULL
Notice: Undefined index: invoice_no in C:\xampp\htdocs\billing_application\pages\delivery_challan_add.php on line 450
it points out invoice_no even-though i have already assigned the variable already using POST method.
<?php 
	session_start(); 

	if (!isset($_SESSION['username'])) {
		$_SESSION['msg'] = "You must log in first";
		header('location: login.php');
	}

	if (isset($_GET['logout'])) {
		session_destroy();
		unset($_SESSION['username']);
		header("location: login.php");
	}

?>

<?php

require_once ('../inc/connect.php');
require_once ('delivery_challan_save.php');

if( !empty( $_POST ) ){
	try{
		$data = saveInvoice( $_POST );
		
		if( isset($data['success']) && $data['success']){
			$_SESSION['success'] = 'Delivery Challan Saved Successfully!';
			header('Location: invoice_view_all.php');exit;
		} else {
			$_SESSION['success'] = 'Delivery Challan Save failed, try again.';
		}
	} catch (Exception $e) {
		$_SESSION['error'] = $e->getMessage();
	}
}

 $taxinfo_connect = mysqli_connect('localhost', 'root', '', 'billing_application');
 $tax_query = "SELECT tax_name,tax_value FROM taxinfo";
 $tax_query_result1 = mysqli_query($taxinfo_connect, $tax_query) or die(mysqli_error($taxinfo_connect));
 
 $tax_query_result2 = mysqli_query($taxinfo_connect, $tax_query) or die(mysqli_error($taxinfo_connect));
 $options = "";
 while($row2 = mysqli_fetch_array($tax_query_result2)){
	 $options = $options. "<option>$row2[1]</option>";
 }
 
 


 /* if(isset($_POST['quote_add']))
{
 // variables for input data
 $quotation_date = mysqli_real_escape_string($connection, $_POST['quotation_date']);
 $quote_your_ref_no = mysqli_real_escape_string($connection, $_POST['quote_your_ref_no']);
 $quote_your_ref_no_date = mysqli_real_escape_string($connection, $_POST['quote_your_ref_no_date']);
 $quotation_terms_payment = mysqli_real_escape_string($connection, $_POST['quotation_terms_payment']);
 $quotation_packing_charges = mysqli_real_escape_string($connection, $_POST['quotation_packing_charges']);
 $quotation_transport_charges = mysqli_real_escape_string($connection, $_POST['quotation_transport_charges']);
 $quotation_remarks = mysqli_real_escape_string($connection, $_POST['quotation_remarks']);
 $quotation_sales_tax = mysqli_real_escape_string($connection, $_POST['quotation_sales_tax']);
 $quotation_delivery = mysqli_real_escape_string($connection, $_POST['quotation_delivery']);
 $quotation_validity = mysqli_real_escape_string($connection, $_POST['quotation_validity']);
 $quotation_sub_total = mysqli_real_escape_string($connection, $_POST['quotation_sub_total']);
 
 // variables for input data
 
 $customer_code = mysqli_real_escape_string($connection, $_POST['customer_code']);
 $customer_name = mysqli_real_escape_string($connection, $_POST['customer_name']);

 // variable for product details -- ADDED NEW
 	$invoice_no = mysqli_real_escape_string($connection, $_POST['invoice_no']);
	//$invoice_no = mysqli_real_escape_string( $connection, trim( $data['invoice_no'] ) );
 
 
 // sql query for inserting data into database
 
        $sql_query1 = "INSERT INTO quotationinfo (quotation_date,quote_your_ref_no,quote_your_ref_no_date,quotation_terms_payment,quotation_packing_charges,
				      quotation_transport_charges,quotation_remarks,quotation_sales_tax,quotation_delivery,quotation_validity,quotation_sub_total,
					  customer_code,customer_name) 
				VALUES('$quotation_date','$quote_your_ref_no','$quote_your_ref_no_date','$quotation_terms_payment','$quotation_packing_charges',
						'$quotation_transport_charges','$quotation_remarks','$quotation_sales_tax','$quotation_delivery','$quotation_validity',
						'$quotation_sub_total','$customer_code','$customer_name')";
						
			
 
		$result1 = mysqli_query($connection, $sql_query1) or die(mysqli_error($connection));
		
		//$result2 = mysqli_query($connection, $sql_query2) or die(mysqli_error($connection));
        
        
        // sql query for inserting data into database
		
		if($result1 ){
		$smsg = "Successfully inserted data, Insert New data.";
		}else{
		$fmsg = "Data not inserted, please try again later.";
	}
 
}  */

if(isset($_POST['quote_add'])){
//$invoice_no = mysqli_real_escape_string($connection, $_POST['invoice_no']);


$invoice_no=$_POST['invoice_no'];
}

?>







<!DOCTYPE html>
<html lang="en">

<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Delivery Challan | SN Dynamics</title>

    <!-- Bootstrap Core CSS -->
    <link href="../vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">

    <!-- MetisMenu CSS -->
    <link href="../vendor/metisMenu/metisMenu.min.css" rel="stylesheet">

    <!-- Custom CSS -->
    <link href="../dist/css/sb-admin-2.css" rel="stylesheet">

    <!-- Morris Charts CSS -->
    <link href="../vendor/morrisjs/morris.css" rel="stylesheet">

    <!-- Custom Fonts -->
    <link href="../vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
<style>
#result {
	height:20px;
	font-size:16px;
	font-family:Arial, Helvetica, sans-serif;
	color:#333;
	padding:5px;
	margin-bottom:10px;
	background-color:#FFFF99;
}
#country{
	padding:1px;
	border:1px #3366CC solid;
	font-size:13px;
}
.suggestionsBox {
	position: absolute;
	left: 0px;
	top:0px;
	margin: 23px 0px 0px 0px;
	width: 150px;
	padding:0px;
	background-color: #ccc;
	border-top: 1px solid #ccc;
}
.suggestionList {
	margin: 0px;
	padding: 0px;
}

.suggestionList ul{
	padding: 0px;
}

.suggestionList ul li {
	list-style:none;
	margin: 0px;
	padding: 6px;
	border-bottom:1px dotted #666;
	cursor: pointer;
	background-color: #ccc;
}
.suggestionList ul li:hover {
	background-color: #FC3;
	color:#000;
}

.load{
background-image:url(images/loader.gif);
background-position:right;
background-repeat:no-repeat;
}

#suggest {
	position:relative;
}


.ui-autocomplete li{
	list-style:none;
	margin: 0px;
	padding: 6px;
	border-bottom:1px dotted #666;
	cursor: pointer;
	background-color: #ccc;
	width: 500px;
}

select#tax{
	max-width: 120px;
	max-height: 28px;
}

input#taxAmount, input#invoice_packing_delivery_charges{
	max-height: 32px;
	max-width: 150px;
}
</style>	



</head>

<body>

    <div id="wrapper">

        <!-- Navigation -->
        <?php require_once('../inc/menus.php'); ?>

        <div id="page-wrapper">
            <div class="row">
                <div class="col-lg-12">
                    <h1 class="page-header">Add Delivery Challan</h1>
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->
            
            <div class="row">
                <div class="col-lg-12">
                    
                    <!-- /.panel -->
                    <div class="panel panel-default">
                       <!-- <div class="panel-heading">
                            <i class="fa fa-bar-chart-o fa-fw"></i> Bar Chart Example
                            <div class="pull-right">
                                <div class="btn-group">
                                    <button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown">
                                        Actions
                                        <span class="caret"></span>
                                    </button>
                                    <ul class="dropdown-menu pull-right" role="menu">
                                        <li><a href="#">Action</a>
                                        </li>
                                        <li><a href="#">Another action</a>
                                        </li>
                                        <li><a href="#">Something else here</a>
                                        </li>
                                        <li class="divider"></li>
                                        <li><a href="#">Separated link</a>
                                        </li>
                                    </ul>
                                </div>
                            </div>
                        </div> -->
                        <!-- /.panel-heading -->
                        <div class="panel-body">
						
						<form role="form" method="post" class="invoice-form" id="invoice-form" action="<?php echo $_SERVER['PHP_SELF']; ?>" novalidate>
						
						<?php if(isset($smsg)){ ?><div class="alert alert-success" role="alert"> <?php echo $smsg; ?> </div><?php } ?>
						<?php if(isset($fmsg)){ ?><div class="alert alert-danger" role="alert"> <?php echo $fmsg; ?> </div><?php } ?>

                            <div class="row">
                                <div class="col-lg-6">
                                    <div class="table-responsive">
                                        <table class="table table-bordered table-hover table-striped">
                                            <thead>
                                                <tr>
                                                  <!--  <th>#</th>
                                                    <th>Date</th>
                                                    <th>Time</th>
                                                    <th>Amount</th> -->
                                                </tr>
                                            </thead>
                                            <tbody>
												
												<tr>
                                                    <td>D.C. No</td>
                                                    <td><input type="text" name="delivery_challan_no" id="delivery_challan_no" placeholder="Auto D.C. No" readonly></td>
                                                    
                                                </tr>
												<tr>
                                                    <td>Invoice No</td>
													<td>
													<div id="suggest"><input type="text" name="invoice_no" id="invoice_no"  onkeyup="suggest(this.value);" onblur="fill();"  placeholder="Auto Load">
														<div class="suggestionsBox" id="suggestions" style="display: none;">
															<div class="suggestionList" id="suggestionsList"> &nbsp; </div>
														</div>
													</div>
													</td>
                                                                                                        
                                                </tr>											
                                                <tr>
                                                    <td>Customer Code</td>
													
                                                    <td><input type="text" name="customer_code" id="customer_code" placeholder="Auto Search" readonly></td>
                                                    
                                                </tr>
												
												<tr style="display:none;">
                                                    <td>Address</td>
													
                                                    <td>
													<input type="text" name="customer_address_1" id="customer_address_1" placeholder="Auto Search">
                                                    <input type="text" name="customer_address_2" id="customer_address_2" placeholder="Auto Search">
													<input type="text" name="customer_city" id="customer_city" placeholder="Auto Search">
													<input type="text" name="customer_state" id="customer_state" placeholder="Auto Search">
													<input type="text" name="customer_pincode" id="customer_pincode" placeholder="Auto Search">
													<input type="text" name="customer_phone_no" id="customer_phone_no" placeholder="Auto Search">
													<input type="text" name="customer_mobile_no" id="customer_mobile_no" placeholder="Auto Search">
													<input type="text" name="customer_tin_no" id="customer_tin_no" placeholder="Auto Search">  
													</td>
                                                </tr>
												<tr style="display:none;">
                                                    <td>Contact Person</td>
													
                                                    <td><input type="text" name="contact_person" id="contact_person" placeholder="Auto Search"></td>
                                                    
                                                </tr>
												
                                                <tr>
                                                    <td>Purchase Order No</td>
                                                    <td><input type="text" id="invoice_purchase_order_no" name="invoice_purchase_order_no"></td>
                                                </tr>
                                                
                                                
												
												
                                            </tbody>
                                        </table>
                                    </div>
                                    <!-- /.table-responsive -->
                                </div>
								
								
								<div class="col-lg-6">
                                    <div class="table-responsive">
                                        <table class="table table-bordered table-hover table-striped">
                                            <thead>
                                                <tr>
                                                  <!--  <th>#</th>
                                                    <th>Date</th>
                                                    <th>Time</th>
                                                    <th>Amount</th> -->
                                                </tr>
                                            </thead>
                                            <tbody>
											
												<tr>
                                                    <td>D.C. Date</td>
                                                    <td><input type="date" name="delivery_challan_date" id="delivery_challan_date"></td>
                                                    
                                                </tr>
												<tr>
                                                    <td>Invoice Date</td>
                                                    <td><input type="date" name="invoice_date" id="invoice_date"></td>
                                                    
                                                </tr>
												<tr>
                                                    <td>Customer Name</td>
                                                    <td>
													<!-- <div id="suggest1"><input type="text" name="customer_name" id="customer_name"  onkeyup1="suggest(this.value);" onblur="fill();"  placeholder="Auto Load">
														<div class="suggestionsBox1" id="suggestions1" style="display: none;">
															<div class="suggestionList1" id="suggestionsList1"> &nbsp; </div>
														</div>
													</div> -->
													<input type="text" name="customer_name" id="customer_name" readonly>
													</td>
                                                    
                                                </tr>
												<tr>
                                                    <td>Purchase Order Date</td>
                                                    <td><input type="date" name="invoice_purchase_order_date" id="invoice_purchase_order_date"></td>
                                                </tr>
												
                                                
												
                                            </tbody>
                                        </table>
                                    </div>
                                    <!-- /.table-responsive -->
                                </div>
								
								
								<!-- Table Line -->
								<div class="col-lg-12">
								
								
								
								<h4> Product Details </h4>
                                    <div class="table-responsive">
						<table class="table table-bordered table-hover" id="quotationTable">
							<thead>
								<tr>
									<!--<th width="2%"><input id="check_all" class="formcontrol" type="checkbox"/></th>-->
									<th width="15%">Product Code</th>
									<th width="38%">Product Name</th>
									<!--<th width="15%">Price</th>-->
									<th width="15%">Quantity</th>
									<!--<th width="15%">Total</th>-->
								</tr>
							</thead>
							<tbody>
							
							<!--   ***** THIRU SHARED AUTOSEARCH ***
								<tr>
									<td><input class="case" type="checkbox"/></td>
									<td><input type="text" name="product_code" id="product_code" placeholder="Auto Search"></td>	
								
								<td>
									<div id="suggest_1"><input type="text" name="product_name" id="product_name"  onkeyup="suggestproduct(this.value);" onblur="fill();"  placeholder="Auto Load">
									<div class="suggestionsBox_1" id="suggestions_1" style="display: none;">
									<div class="suggestionList_1" id="suggestionsList_1"> &nbsp; </div>
									</div>
									</div>
									</td>
								
									<td><input type="text" name="product_price" id="product_price" placeholder="Auto Search"></td>
									<td><input type="text" name="product_quantity" id="product_quantity" placeholder="Auto Search"></td>
									<td><input type="text" name="total_price" id="total_price" placeholder="Auto Search"></td>
								</tr>
								
							-->	
							<?php var_dump($_REQUEST); ?>
							 <?php echo var_dump($productdetailview); ?>
							<?php 
												
								//$invoice_no = $_POST['invoice_no'];				
								$select_productdetail_query = "SELECT * FROM invoice_details WHERE invoiceinfo_id='".$_REQUEST['invoice_no']."'";
								$productdetail_query_result = mysqli_query($connection, $select_productdetail_query);	 
								
								
								 while($productdetailview = mysqli_fetch_array($productdetail_query_result)){ ?>
							<tr>
								 <?php echo var_dump($productdetailview); //echo $productdetailview['product_code']; ?>
								 <td><strong><small><?php echo $productdetailview['product_code']; ?></strong></small> </td>
                                 <td style="text-align:left;"><strong><small><?php echo $productdetailview['product_name']; ?></strong></small></td>
								 <td><strong><small><?php echo $productdetailview['product_quantity']; ?></strong></small></td>
							<!--	 <td><strong><small><?php //echo $productdetailview['product_price']; ?></strong></small></td>
                                 <td><strong><small><?php //echo $productdetailview['total_price']; ?></strong></small></td> -->
								 
                            </tr>
							<?php } ?>
							
							<tr>
									<!--<td><input class="case" type="checkbox"/></td> -->
									
									<!-- <td><input type="text" data-type="product_code" name="data[0][product_code]" id="itemNo_1" class="form-control autocomplete_txt1" autocomplete="off"></td>
									<td><input type="text" data-type="product_code" name="data[0][product_code]" id="itemNo_1" value="<?php //echo $productdetailview['product_code']; ?>" class="form-control autocomplete_txt1" autocomplete="off"></td>
									<td><input type="text" data-type="product_name" name="data[0][product_name]" id="itemName_1" value="<?php //echo $productdetailview['product_name']; ?>" class="form-control autocomplete_txt" autocomplete="off"></td>
									<td><input type="number" name="data[0][product_price]" id="price_1" value="<?php //echo $productdetailview['product_quantity']; ?>" class="form-control changesNo" autocomplete="off" onkeypress="return IsNumeric(event);" ondrop="return false;" onpaste="return false;"></td>
									<td><input type="number" name="data[0][product_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="data[0][total_price]" id="total_1" class="form-control totalLinePrice" autocomplete="off" onkeypress="return IsNumeric(event);" ondrop="return false;" onpaste="return false;" readonly></td>
								 --></tr> 
								
							</tbody>
						</table>
					
					<!--		
						<button id="delete" class="btn btn-danger delete" type="button">- Delete</button>
						<button id="addmore" class="btn btn-success addmore" type="button">+ Add More</button>
						<br><br>  -->
					</div>
				</div>
					
					<hr/>
					
					 <!-- end of Table Line -->
							
							<div class="col-lg-12" style="display:none;">	
								<div class="col-lg-6">
                                    <div class="table-responsive">
                                        <table class="table table-bordered table-hover table-striped">
                                            <thead>
                                                <tr>
                                                  <!--  <th>#</th>
                                                    <th>Date</th>
                                                    <th>Time</th>
                                                    <th>Amount</th> -->
                                                </tr>
                                            </thead>
                                            <tbody>
												
                                                <tr>
													<h4>Tax Calculation </h4>
												</tr>
                                                <tr>
                                                    <td> <span style="float:left;padding-top:8px;">IGST Tax &nbsp; </span>
														<!--<select class="form-control" name="tax_percent" id="tax" placeholder="Tax" onkeypress="return IsNumeric(event);" ondrop="return false;" onpaste="return false;" >
															 <?php //echo $options; ?> 
														</select>-->
														<input style="float:right;max-width:150px;" type="text" class="form-control" name="tax_percent_igst" id="tax_igst" placeholder="Tax" onkeypress="return IsNumeric(event);" ondrop="return false;" onpaste="return false;" >
														</td>
                                                    <td>
													<input type="number" class="form-control" name="tax_value_igst" id="taxAmount_igst" placeholder="Tax" onkeypress="return IsNumeric(event);" ondrop="return false;" onpaste="return false;" readonly>
													</td>
													
                                                </tr>
												
												
												<tr>
                                                    <td> <span style="float:left;padding-top:8px;">CGST Tax &nbsp; </span>
														
														<input style="float:right;max-width:150px;" type="text" class="form-control" name="tax_percent_cgst" id="tax_cgst" placeholder="Tax" onkeypress="return IsNumeric(event);" ondrop="return false;" onpaste="return false;" >
														</td>
                                                    <td>
													<input type="number" class="form-control" name="tax_value_cgst" id="taxAmount_cgst" placeholder="Tax" onkeypress="return IsNumeric(event);" ondrop="return false;" onpaste="return false;" readonly>
													</td>
													
                                                </tr>
												
												<tr>
                                                    <td> <span style="float:left;padding-top:8px;">SGST Tax &nbsp; </span>
														
													<input style="float:right;max-width:150px;" type="text" class="form-control" name="tax_percent_sgst" id="tax_sgst" placeholder="Tax" onkeypress="return IsNumeric(event);" ondrop="return false;" onpaste="return false;" >
														</td>
                                                    <td>
													<input type="number" class="form-control" name="tax_value_sgst" id="taxAmount_sgst" placeholder="Tax" onkeypress="return IsNumeric(event);" ondrop="return false;" onpaste="return false;" readonly>
													</td>
													
                                                </tr>
												
												<tr>
                                                    <td>Remarks</td>
                                                    <td><input type="text" name="invoice_remarks"></td>
                                                </tr>
                                                
												
                                                
												
                                                <!--
												<tr>
                                                    <td>Quotation Delivery</td>
                                                    <td><input type="text" name="quotation_delivery"></td>
                                                </tr> -->
												
												
												
												
												
                                            </tbody>
                                        </table>
                                    </div>
                                    <!-- /.table-responsive -->
                                </div>
								
								
								<div class="col-lg-6">
                                    <div class="table-responsive">
                                        <table class="table table-bordered table-hover table-striped">
                                            <thead>
                                                <tr>
                                                  <!--  <th>#</th>
                                                    <th>Date</th>
                                                    <th>Time</th>
                                                    <th>Amount</th> -->
                                                </tr>
                                            </thead>
                                            <tbody>
												
												<tr> <h4>&nbsp;</h4>
												</tr>
												<tr>
                                                    <td>Sub Total</td>
                                                    <td><input type="text" id="subTotal" name="invoice_sub_total" placeholder="Subtotal" onkeypress="return IsNumeric(event);" ondrop="return false;" onpaste="return false;" readonly></td>
                                                </tr>
												<tr>
                                                    <td>Discount (if Any)</td>
                                                    <td><input type="text" id="discount" name="invoice_discount" placeholder="in Rupees" onchange="calculateTotal()" ondrop="return false;" onpaste="return false;"></td>	
												</tr>
												<tr>
                                                    <td>Packing / Delivery Charges</td>
                                                    <td><input type="number" id="invoice_packing_delivery_charges" name="invoice_packing_delivery_charges" onchange="calculateTotal()" ondrop="return false;" onpaste="return false;"></td>
                                                </tr>
												<!--<tr>
                                                    <td>Transport Charges</td>
                                                    <td><input type="text" name="quotation_transport_charges"></td>
                                                </tr>-->
                                                <tr>
                                                    <td>Total</td>
                                                    <td><input type="number" class="form-control" name="invoice_total" id="totalAftertax" placeholder="Total" onkeypress="return IsNumeric(event);" ondrop="return false;" onpaste="return false;" readonly></td>
                                                </tr>
                                                
                                                
												
                                            </tbody>
                                        </table>
                                    </div>
                                    <!-- /.table-responsive -->
                                </div>
							</div>	
							
							<!-- Address Blcock -->
							<div class="col-lg-12">	
								<div class="col-lg-6">
                                    <div class="table-responsive">
                                        <table class="table table-bordered table-hover table-striped">
                                            <thead>
                                                <tr>
                                                  <!--  <th>#</th>
                                                    <th>Date</th>
                                                    <th>Time</th>
                                                    <th>Amount</th> -->
                                                </tr>
                                            </thead>
                                            <tbody>
												
                                                <tr style="display:none;">
													<h4 style="display:none;">
														<input type="checkbox" value="copy" onClick="copy();" /> My Billing and Shipping are Same</h4>
												</tr>
                                                
												

												
                                                <tr class="what_to_set">
                                                    <td>Customer Name</td>
                                                    <td><input type="text" name="customer_shipping_name" placeholder="Company Name" id="customer_shipping_name" readonly></td>
                                                    
                                                </tr>
                                                <tr>
                                                    <td>Contact Person</td>
                                                    <td><input type="text" name="contact_person_shipping" id="contact_person_shipping" readonly></td>
                                                </tr>
                                                <tr>
                                                    <td>Address 1</td>
                                                    <td><input type="text" name="customer_shipping_address_1" id="customer_shipping_address_1" readonly></td>
                                                </tr>
                                                <tr>
                                                    <td>Address 2</td>
                                                    <td><input type="text" name="customer_shipping_address_2" id="customer_shipping_address_2" readonly></td>
                                                </tr>
                                                <tr>
                                                    <td>City</td>
                                                    <td><input type="text" name="customer_shipping_city" id="customer_shipping_city" readonly></td>
                                                </tr>
                                                
                                                
												
                                                <!--
												<tr>
                                                    <td>Quotation Delivery</td>
                                                    <td><input type="text" name="quotation_delivery"></td>
                                                </tr> -->
												
												
												
												
												
                                            </tbody>
                                        </table>
                                    </div>
                                    <!-- /.table-responsive -->
                                </div>
								
								
								<div class="col-lg-6">
                                    <div class="table-responsive">
                                        <table class="table table-bordered table-hover table-striped">
                                            <thead>
                                                <tr>
                                                  <!--  <th>#</th>
                                                    <th>Date</th>
                                                    <th>Time</th>
                                                    <th>Amount</th> -->
                                                </tr>
                                            </thead>
                                            <tbody>
												
												<tr style="display:none;"> <h4 style="display:none;">
													&nbsp;	<input type="button" name="billing_shipping_not_same" value="No, My Billing and Shipping are NOT Same" onClick="reset();" /> </h4>
												
												</tr>
												<tr>
                                                    <td>State</td>
                                                    <td><input type="text" name="customer_shipping_state" id="customer_shipping_state" readonly></td>
                                                </tr>
                                                <tr>
                                                    <td>Pincode</td>
                                                    <td><input type="text" name="customer_shipping_pincode" id="customer_shipping_pincode" readonly></td>
                                                </tr>
                                                <tr>
                                                    <td>Phone No</td>
                                                    <td><input type="text" name="customer_shipping_phone_no" id="customer_shipping_phone_no" readonly></td>
                                                </tr>
												<tr>
                                                    <td>Mobile No</td>
                                                    <td><input type="text" name="customer_shipping_mobile_no" id="customer_shipping_mobile_no" readonly></td>
                                                </tr>
												
                                                <tr>
                                                    <td>TIN No</td>
                                                    <td><input type="text" name="customer_shipping_tin_no" id="customer_shipping_tin_no" readonly></td>
                                                </tr>
                                                
                                                
                                             
												
                                            </tbody>
                                        </table>
                                    </div>
                                    <!-- /.table-responsive -->
                                </div>
							</div>	
							
							
							
							
								
								<div class="col-lg-4">
                                    <div class="table-responsive">
                                        	
									</div>
								</div>
								
								<div class="col-lg-2">
                                    <div class="table-responsive">
                                        <button id="validatethis" type="submit" class="btn btn-lg btn-success btn-block" name="invoice_add">SAVE</button> 
																						
											
									</div>
								</div>	
								
								<div class="col-lg-3">
                                    <div class="table-responsive">
                                        <a href="invoice_view.php" class="btn btn-lg btn-success btn-block">CANCEL / BACK</a>
																						
											
									</div>
								</div>
					
                                
                                <!-- /.col-lg-8 (nested) -->
                            </div>
                            <!-- /.row -->
							
						</form>	
                        </div>
                        <!-- /.panel-body -->
                    </div>
                    
                </div>
                <!-- /.col-lg-8 -->
               
            </div>
            <!-- /.row -->
        </div>
        <!-- /#page-wrapper -->

    </div>
    <!-- /#wrapper -->

    <!-- jQuery -->
    <script src="../vendor/jquery/jquery.min.js"></script>

    <!-- Bootstrap Core JavaScript -->
    <script src="../vendor/bootstrap/js/bootstrap.min.js"></script>

    <!-- Metis Menu Plugin JavaScript -->
    <script src="../vendor/metisMenu/metisMenu.min.js"></script>

    <!-- Morris Charts JavaScript -->
    <script src="../vendor/raphael/raphael.min.js"></script>
    <script src="../vendor/morrisjs/morris.min.js"></script>
    <script src="../data/morris-data.js"></script>

    <!-- Custom Theme JavaScript -->
    <script src="../dist/js/1sb-admin-2.js"></script>



	
<!-- Auto Load Functionality for Invoice No -->	
	<script>
function suggest(inputString){
		
		if(inputString.length == 0) {
			$('#suggestions').fadeOut();
		} else {
		$('#invoice_no').addClass('load');
			$.post("autosuggest_invoicedetails.php", {queryString: ""+inputString+""}, function(data){
				if(data.length >0) {
					$('#suggestions').fadeIn();
					$('#suggestionsList').html(data);
					$('#invoice_no').removeClass('load');
					//jQuery("#delivery_address1").attr('checked', 'checked');

				}
			});
		}
	}

	
	function fill(thisValue) {
	var a=thisValue;
	var b=a.split("~");
	setTimeout("$('#suggestions').fadeOut();", 1);
		$('#invoice_no').val(b[0]);
		$('#invoice_date').val(b[1]);
		$('#invoice_purchase_order_no').val(b[2]);
		$('#invoice_purchase_order_date').val(b[3]);
		$('#customer_code').val(b[4]);
		$('#customer_shipping_name').val(b[5]);
		$('#contact_person_shipping').val(b[6]);
		$('#customer_shipping_address_1').val(b[7]);
		$('#customer_shipping_address_2').val(b[8]);
		$('#customer_shipping_city').val(b[9]);
		$('#customer_shipping_state').val(b[10]);
		$('#customer_shipping_pincode').val(b[11]);
		$('#customer_shipping_phone_no').val(b[12]);
		$('#customer_shipping_mobile_no').val(b[13]);
	
	}
</script>

	
<!-- Auto Load Functionality for Customer Name -->	
<!-- 	<script>
function suggest(inputString1){
		
		if(inputString.length == 0) {
			$('#suggestions1').fadeOut();
		} else {
		$('#customer_name1').addClass('load');
			$.post("autosuggest.php", {queryString: ""+inputString+""}, function(data){
				if(data.length >0) {
					$('#suggestions1').fadeIn();
					$('#suggestionsList1').html(data);
					$('#customer_name1').removeClass('load');
					//jQuery("#delivery_address1").attr('checked', 'checked');

				}
			});
		}
	}

	
	function fill(thisValue) {
	var a=thisValue;
	var b=a.split("~");
	setTimeout("$('#suggestions1').fadeOut();", 1);
		$('#customer_name').val(b[0]);
		$('#customer_code').val(b[1]);
		$('#contact_person').val(b[2]);
		$('#customer_address_1').val(b[3]);
		$('#customer_address_2').val(b[4]);
		$('#customer_city').val(b[5]);
		$('#customer_state').val(b[6]);
		$('#customer_pincode').val(b[7]);
		$('#customer_phone_no').val(b[8]);
		$('#customer_mobile_no').val(b[9]);
		$('#customer_tin_no').val(b[10]);		
	
	}
</script> -->



<!-- Auto Load Functionality for Product Name -->	
<!--<script>
function suggestproduct(inputString){
		
		if(inputString.length == 0) {
			$('#suggestions_1').fadeOut();
		} else {
		$('#product_name').addClass('load');
			$.post("autosuggest_productname.php", {queryString1: ""+inputString+""}, function(data){
				if(data.length >0) {
					$('#suggestions_1').fadeIn();
					$('#suggestionsList_1').html(data);
					$('#product_name').removeClass('load');
					//jQuery("#delivery_address1").attr('checked', 'checked');

				}
			});
		}
	}

	
	function fill(thisValue) {
	var a=thisValue;
	var b=a.split("~");
	setTimeout("$('#suggestions_1').fadeOut();", 1);
		$('#product_name').val(b[0]);
		$('#product_code').val(b[1]);
		$('#product_price').val(b[2]);		
	
	}
</script>

<script>

$(document).ready(function() {
    //this calculates values automatically 
    sum();
    $("#product_price, #product_quantity").on("keydown keyup", function() {
        sum();
    });
});

function sum() {
            var product_price = document.getElementById('product_price').value;
            var product_quantity = document.getElementById('product_quantity').value;
			var result = parseInt(product_price) * parseInt(product_quantity);
			var result1 = parseInt(product_quantity) - parseInt(product_price);
            if (!isNaN(result)) {
                document.getElementById('total_price').value = result;
				document.getElementById('subt').value = result1;
            }
        }

</script>
		
	<!--	-->
	<script src="../js/jquery.min.js"></script>
		<script src="../js/jquery-ui.min.js"></script>
		<script src="../js/bootstrap.min.js"></script>
		<script src="../js/bootstrap-datepicker.js"></script> 
		<script src="../js/auto_invoice.js"></script> 
		
		<!-- <script>
		$("#invoice-form").submit(function() {
		  var quote_your_ref_no = $("#quote_your_ref_no").val();
		  if(quote_your_ref_no == "") {
			alert('Fill all the Fields');
			return false;
		  }
		});
		</script> -->
	
	<!-- Copy from one textbox to another -->	
	<script type="text/javascript">
	function copy()
	{
		var customer_name = document.getElementById("customer_name");
		var contact_person = document.getElementById("contact_person");
		var customer_address_1 = document.getElementById("customer_address_1");
		var customer_address_2 = document.getElementById("customer_address_2");
		var customer_city = document.getElementById("customer_city");
		var customer_state = document.getElementById("customer_state");
		var customer_pincode = document.getElementById("customer_pincode");
		var customer_phone_no = document.getElementById("customer_phone_no");
		var customer_mobile_no = document.getElementById("customer_mobile_no");
		var customer_tin_no = document.getElementById("customer_tin_no");
		
		var customer_shipping_name = document.getElementById("customer_shipping_name");
		var contact_person_shipping = document.getElementById("contact_person_shipping");
		var customer_shipping_address_1 = document.getElementById("customer_shipping_address_1");
		var customer_shipping_address_2 = document.getElementById("customer_shipping_address_2");
		var customer_shipping_city = document.getElementById("customer_shipping_city");
		var customer_shipping_state = document.getElementById("customer_shipping_state");
		var customer_shipping_pincode = document.getElementById("customer_shipping_pincode");
		var customer_shipping_phone_no = document.getElementById("customer_shipping_phone_no");
		var customer_shipping_mobile_no = document.getElementById("customer_shipping_mobile_no");
		var customer_shipping_tin_no = document.getElementById("customer_shipping_tin_no");
		
		customer_shipping_name.value = customer_name.value;
		contact_person_shipping.value = contact_person.value;
		customer_shipping_address_1.value = customer_address_1.value;
		customer_shipping_address_2.value = customer_address_2.value;
		customer_shipping_city.value = customer_city.value;
		customer_shipping_state.value = customer_state.value;
		customer_shipping_pincode.value = customer_pincode.value;
		customer_shipping_phone_no.value = customer_phone_no.value;
		customer_shipping_mobile_no.value = customer_mobile_no.value;
		customer_shipping_tin_no.value = customer_tin_no.value;
		
	}
	
	</script>	
	
	<!-- RESET textbox DOESNT WORK!-->	
	<script type="text/javascript">
	function reset()
	{
		customer_shipping_name.value = "";
		contact_person_shipping.value = "";
		customer_shipping_address_1.value = customer_address_1.value;
		customer_shipping_address_2.value = customer_address_2.value;
		customer_shipping_city.value = customer_city.value;
		customer_shipping_state.value = customer_state.value;
		customer_shipping_pincode.value = customer_pincode.value;
		customer_shipping_phone_no.value = customer_phone_no.value;
		customer_shipping_mobile_no.value = customer_mobile_no.value;
		customer_shipping_tin_no.value = customer_tin_no.value;
	}
	
	</script>
	
	<!-- If checkbox selected to SHOW textbox! #NOT USED -->	
	<script type="text/javascript">
	$('[type="checkbox"][name="not_same"]').change(function(){
  $('tr.what_to_set').toggle(this.checked);
});
	</script>
	
	<style type="text/css">
	tr.what_to_set{
		<!--display: none;-->
	}
	</style>
	
	<!-- Date Picker with future select restriction #NOT WORKING -->	
	<script type="text/javascript">
	$(function () {
     $('#invoice_date').datetimepicker({  
         minDate:new Date()
      });
 });


	</script>
	
	
</body>

</html>

Open in new window

There's no need to post 1000 lines of code - you've already posted your page :)

You need to dump the REQUEST array just to make sure it's in there. You build your query like this:

$select_productdetail_query = "SELECT * FROM invoice_details WHERE invoiceinfo_id='".$_REQUEST['invoice_no']."'";

And this is giving you an undefined index error! Therefore, no matter what you think you've done, the REQUEST array does not contain an invoice_no key. Dumping the REQUEST array will show you exactly that.

I don't really understand what you mean when you say you've assigned the variable using the POST method. The POST array is automatically filled when you POST a form to a script (i.e. click on the Submit of a form that has it's method set to POST)
OK. Having a quick look through your page, you have a form containing the invoice_no textbox, and then futher down you have the query. The invoice_no won't exist in the POST array until AFTER you've posted your form, so the first time you load up this page (unless it's posted from somewhere else), then you will get errors.

Your logic is flawed, so you'll need to address that
I think that your problem starting from  this line of code and function (Remember that all the code is executing from top to bottom):
The variable $invoice_no comes from element (line 105):
if(isset($_POST['quote_add'])){
$invoice_no=$_POST['invoice_no'];
}

Open in new window

In this code you define and assign the $invoice_no variable from this element (line 306)
<div id="suggest"><input type="text" name="invoice_no" id="invoice_no"  onkeyup="suggest(this.value);" onblur="fill();"  placeholder="Auto Load">

Open in new window

You must check first if you have the $_POST['quote_add']) var.You can do this like that:

var_dump($_POST['quote_add']));
if(isset($_POST['quote_add'])){
$invoice_no=$_POST['invoice_no'];
}

Open in new window

If  the $_POST['quote_add'])  exist then you must check if the $_POST['invoice_no'] variable exist...
Has the input element a value?As I see no.
Also the input element has the fill() javascript function (lines 814 till 833):
function fill(thisValue) {
	var a=thisValue;
	var b=a.split("~");
	setTimeout("$('#suggestions').fadeOut();", 1);
		$('#invoice_no').val(b[0]);
		$('#invoice_date').val(b[1]);
		$('#invoice_purchase_order_no').val(b[2]);
		$('#invoice_purchase_order_date').val(b[3]);
		$('#customer_code').val(b[4]);
		$('#customer_shipping_name').val(b[5]);
		$('#contact_person_shipping').val(b[6]);
		$('#customer_shipping_address_1').val(b[7]);
		$('#customer_shipping_address_2').val(b[8]);
		$('#customer_shipping_city').val(b[9]);
		$('#customer_shipping_state').val(b[10]);
		$('#customer_shipping_pincode').val(b[11]);
		$('#customer_shipping_phone_no').val(b[12]);
		$('#customer_shipping_mobile_no').val(b[13]);
	
	}

Open in new window

This js function assignvalues in various elements (as I understand it takes the input element  values as parameter and then re assign to all these elements values).Where it comes this parameter?
Notice: Undefined index: invoice_no in C:\xampp\htdocs\billing_application\pages\delivery_challan_add.php on line 443

Notice: Undefined index: invoice_no in C:\xampp\htdocs\billing_application\pages\delivery_challan_add.php on line 444
array(0) { }
You can't just load your page into a browser and expect the POST or REQUEST values to exist. They will only exist AFTER you've clicked on your submit button and sent the values from your form back into your page.

Have a look at the very simple example:

<!DOCTYPE html>
<html lang="en">
    <head>
        <title>Chris Stanyon</title>
    </head>
    <body>

        <h2>The POST array</h2>
            <?php var_dump($_POST); ?>

        <h2>The Form</h2>
            <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
                <div><label>Invoice ID:<label> <input type="text" name="invoiceId" value="123" /></div>
                <div><input type="submit" name="submit" value="Send"></div>
            </form>

    </body>
</html>

Open in new window

When you load this page up in your browser, you'll see that the POST array is empty, so $_POST['invoiceId'] doesn't exist. Now if you click on the button, the content of the form will be POSTed back to the same page, and you'll see that the POST array contains the values from the form, so $_POST['invoiceId'] does now exist.

Bottom line is that you can't use the POST array if you haven't posted anything to your page.
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.