Note that there are some explanatory texts on larger screens.

plurals
  1. POStay on current page after POST data
    primarykey
    data
    text
    <p>i have form which genrate from a specific search button.the newly generated form has several form wich can update it's own data how to doing such a update without any affect to current page. because of search result and search parameter should not be change.<br> eventually question in sort, give me an idea to "update each record based on query search while displaying it'. </p> <p>ex:</p> <pre><code>&lt;pre&gt; **name:[** k% **] branch:[** acc **] SEARCH** &gt;&gt;&gt;&gt;search form EMPID | NAME | BRANCH | EDIT | 1 | kamal | acc | edit | &gt;&gt;&gt;&gt;&gt;&gt;dynamicaly generated form based query serch 2 | kapila | acc | edit | &gt;&gt;&gt;&gt;&gt;&gt;dynamicaly generated form based query serch &lt;/pre&gt; </code></pre> <p>thank you.. here my try </p> <pre><code>&lt;?php session_start(); include("../../config/config.inc.php"); ?&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt; &lt;link rel="stylesheet" type="text/css" href="../../css/tbl.css"/&gt; &lt;script type="text/javascript" src="../../jquery/formControll.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; function autoSubmit(){ document.forms['searchForm'].action=SCRIPT_NAME; document.forms['searchForm'].submit(); alert("done"); return true; } &lt;/script&gt; &lt;title&gt;OT Detail&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;?php $errors = array(); $htmlcode=""; $me = $_SERVER['PHP_SELF']; if(isset($_GET["invalid"])) //that means this is a redirected session { //form data default value initialization goes here $Year=$_GET["Year"]; $Month=$_GET["Month"]; echo "&lt;br&gt;&lt;br&gt;&lt;strong&gt;ERROR: "; foreach($_GET["errors"] as $k=&gt;$v) echo "&lt;font color=red &gt;".$v."&lt;/font&gt;"; echo "&lt;/strong&gt;"; } else//if $_GET["invalid"] is not define then this is not redirecting session { //form data default value initialization goes here $Year=date("Y"); $Month=date("m"); } //for sequrity reasons we check weather 'REQUEST_METHOD'== 'POST' if ($_SERVER['REQUEST_METHOD'] == 'POST'){ //server side manual form validation goes here if (!$_POST['Year']) $errors[0] = "Year ?"; if (!$_POST['Month']) $errors[1] = "Month?"; if (count($errors)&gt;0){ header("Location:setOtPermit.php?invalid=1&amp;Year=".$_POST["Year"]."&amp;Month=".$_POST["Month"]."&amp;errors=".$errors); exit; } else //no error { //get post array foreach($_POST as $key=&gt;$value){ if ($key!="Search"){ $value=htmlentities(stripslashes(strip_tags($value))); ${$key}=$value; }//if $key }//4e //******* building sql for search $sql="SELECT branch FROM ".$tbl_name2." WHERE empNo=".$_SESSION['resideFigure']; $result=mysql_query($sql,$con)or die("cannot query"); $row=mysql_fetch_array($result,MYSQL_NUM); $myBranch="Finance";//$row[0]; //echo $myBranch; $sql="select * from ".$tbl_name4." e where e.empNo in( select d.empNo from ".$tbl_name2." d where d.branch='".$myBranch."') and e.empNo=000123 and e.permitMonth=1"; //echo $sql; $result=mysql_query($sql,$con)or die("cannot query"); //*** search result feching into table goes here if(mysql_num_rows($result)&gt;0) { $htmlcode.="&lt;center&gt;&lt;table id='myDisplay'&gt;"; $htmlcode.="&lt;tr&gt;"; for($i = 0; $i &lt; mysql_num_fields($result); $i++) { $htmlcode.="&lt;th&gt;".mysql_field_name($result,$i)."&lt;/th&gt;"; }//for mysql_num_fields $htmlcode.="&lt;/tr&gt;"; $rowAlter=true; while($row = mysql_fetch_assoc($result)) { $htmlcode.="&lt;form name='myform[]' method='POST' action='".$me."' onSubmit='return validateForm()'&gt;"; if($rowAlter) {$htmlcode.="&lt;tr&gt;"; $rowAlter=false; } else { $htmlcode.="&lt;tr class='alt'&gt;"; $rowAlter=true; } foreach($row as $k=&gt;$v) { $htmlcode.="&lt;td&gt;&lt;input type='text' name='mydata[]' value='".$v."'&gt;&lt;/td&gt;"; }//4e $htmlcode.="&lt;td&gt;&lt;input type='submit' name='Update' onclick='autoSubmit()' value='Update'&gt;&lt;/td&gt;&lt;/tr&gt;"; }//while $htmlcode.="&lt;/form&gt;&lt;/table&gt;&lt;/center&gt;"; } else//when data not fetched { echo "&lt;br&gt;&lt;br&gt;&lt;font color=blue &gt;It seems to be you have not done any OT Permission!&lt;/font&gt;"; } }//else error count }//if $_SERVER ?&gt; &lt;center&gt;&lt;form name="searchForm" method="POST" action="&lt;?php echo strip_tags($me);?&gt;" onSubmit="return validateForm()"&gt; &lt;table border="0" cellspacing="0" cellpadding="2"&gt; &lt;tr&gt; &lt;td&gt;Year&lt;/td&gt;&lt;td&gt;&lt;input type="text" name="Year" value="&lt;?php echo $Year;?&gt;"&gt;&lt;/td&gt; &lt;td&gt;Month&lt;/td&gt;&lt;td&gt;&lt;input type="text" name="Month" value="&lt;?php echo $Month;?&gt;"&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="submit" name="Search" value="Search"&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="reset" name="Reset" value="Reset"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form&gt;&lt;/center&gt; &lt;script type="text/javascript"&gt;SetHandlers()&lt;/script&gt; &lt;?php //display result as table if (count($errors)==0) echo $htmlcode; //for sequrity reasons &amp; confirm to dynamic form are submited we check weather 'REQUEST_METHOD'== 'POST' if ($_SERVER['REQUEST_METHOD'] == 'POST' &amp;&amp; isset($_POST['Update'])){} echo "if success i can do this its not difficult,but things is result desapper"; ?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload