jquery - How to save a variables value out of the loop in PHP? -


<?php //connecting database  define('db_host', 'localhost'); define('db_name', 'visitor_list');  define('db_user','root');    define('db_password',''); $con=mysql_connect(db_host,db_user,db_password) or die("failed connect            mysql: " . mysql_error()); $db=mysql_select_db(db_name,$con) or die("failed      connect mysql: " .  mysql_error()); //inserting record database $dat1 = date("d"); $moth1 = date("m");  $year1 = date("y"); $sql2 = 'select *  list1 order card_no desc limit 1;'; $retval = mysql_query($con,$sql2 ); while($row = mysql_fetch_array($retval, mysql_assoc)) { /*echo "{$row['card_no']}";*/ $in= $row['card_no']; $in++; }  $ap_ty = $_post['ap_ty']; $per = $_post['per']; $no_vis = $_post['no_vis']; $nm_vis = $_post['nm_vis']; $co_nm = $_post['co_nm']; $ad = $_post['ad']; $po = $_post['po']; $ty_vis = $_post['ty_vis']; $met_nm = $_post['met_nm']; $dep = $_post['dep']; $des = $_post['des']; $por_met = $_post['por_met']; $vad = $_post['vad'];  if(!isset($_post['submit'])){ $query = "insert list1    (card_no,d1,m1,y1,app_ty,no_per,area_vis,nm,com_nm,add1,pho,ty1_vis,met_with,depart,desi,pur_meet,vad_up) values     ('$in','$dat1','$moth1','$year1','$ap_ty','$per','$no_vis','$nm_vis','$co_nm','$ad','$po','$ty_vis','$met_nm','$dep','$des','$por_met','$vad')";}  $result = mysql_query($query);  if($result)  {  echo '<script type="text/javascript">  alert("your deatils has been submitted");   </script> ';  header('location:index.php');  }  else   { die('error: '.mysql_error($con)); }   mysql_close($con);   ?> 

i want save $in variables value in query not able save it. @ time of insertion saves value 0 not actual value.

 <input type="text" class="form-control" name="vis_id" value=" <?php                             $dbhost = 'localhost';                             $dbuser = 'root';                             $dbpass = '';                             $conn = mysql_connect($dbhost, $dbuser, $dbpass);                             if(! $conn )                                 {                                 die('could not connect: ' . mysql_error());                                 }                             $sql = 'select *  list1 order card_no desc limit 1;';                             mysql_select_db('visitor_list');                             $retval = mysql_query( $sql, $conn );                             if(! $retval )                             {                                 die('could not data: ' . mysql_error());                             }                             while($row = mysql_fetch_array($retval, mysql_assoc))                             {                                 /*echo "{$row['card_no']}";*/                                 $in= $row['card_no'];                                 $in+                                 $test = $in;                             }                             mysql_close($conn);                          ?>"   disabled> 

this actual code in input box value incrementing me save value of input box file database file.


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -