Jump to content

Update data using button


shebbycs

Recommended Posts

//countercashadminlocation2.php

<?php
session_start();
ini_set('session.bug_compat_warn', 0);
ini_set('session.bug_compat_42', 0);
if (empty($_SESSION['is_logged_in']))
{
 header("Location:login.php");
 die();     // just to make sure no scripts execute
}
?>
<?php
 	mysql_connect("localhost","root") or die(mysql_error());
    mysql_select_db("kime") or die(mysql_error());
	$a=$_SESSION['branchcodename'];
     if (isset($_POST["submit"]))
    { 
	 $place = $_POST['tempat'];
	 $_SESSION['tempat']=$place;
	 $b= $_SESSION['tempat'];
	 $sql1 = mysql_query("SELECT *,DATE_FORMAT(Form_Date, '%d/%m/%Y %H:%i %p') AS Form_Date FROM counter_cash WHERE Branch_Codename='$place' ORDER BY Form_Date") or die(mysql_error());
	 $sql2 = mysql_query("SELECT ID FROM counter_cash WHERE Check_By ='' AND Branch_Codename='$place' ") or die(mysql_error());
     echo "<body  bgcolor='#F5D16A'>";
     echo "<center><img src ='OK.gif'></center><br>";
     echo "<center><h2>COUNTER CASH CHECKING REPORT</h2>";
	 echo "<table><tr><td><h3>LOCATION</h3></td><td><h3>:</h3></td><td><h3>".$place."</h3></td></tr></table></center>";
     echo "<center><table border = '1'>";
     echo "<tr><th rowspan='2'>ID</th><th rowspan='2'>DATE & TIME</th><th rowspan='2'>CASHIER NAME</th><th colspan='3'>COUNTER CASH</th><th colspan='3'>PETTY CASH</th><th rowspan='2'>SIGN</th><th rowspan='2'>HANDOVER      TO (NAME)</th><th rowspan='2'>SIGN</th><th rowspan='2'>CHECK BY</th><th rowspan='2'>CHECK SYMBOL</th></tr>";	 
     echo "<tr><th>AMOUNT</th><th>SHORTAGE</th><th>EXCESS</th><th>AMOUNT</th><th>SHORTAGE</th><th>REMARK</th></tr>";
     while($report = mysql_fetch_array($sql1))
     {
      echo "<tr align='center'><td>".$report['ID']."</td>";
	  echo "<td>".$report['Form_Date']."</td> ";
      echo "<td>".$report['Cashier_Name']."</td> ";
      echo "<td>RM  ".$report['Counter_Amount']."</td> ";
      echo "<td>RM  ".$report['Counter_Shortage']."</td> ";
      echo "<td>RM  ".$report['Counter_Excess']."</td> ";
      echo "<td>RM  ".$report['Petty_Amount']."</td> ";
      echo "<td>RM  ".$report['Petty_Shortage']."</td> ";
      echo "<td>".$report['Petty_Remark']."</td> ";
      echo "<td>".$report['Cashier_Sign']."</td> ";
      echo "<td>".$report['Handover_Name']."</td> ";
      echo "<td>".$report['Handover_Sign']."</td> ";
	  echo "<td>".$report['Check_By']."</td> ";
	  echo "<td>";
	  echo "<input type='button' name='check[]' value=".$report['ID'].">";
	  echo "</td>";
	

	  
	 
	 }
	 echo"</tr></table></center><br>";
	/* echo"<center><form name='editcheckby' method='post' action='countercashadmineditcheckby2.php'>";
	 echo "<table><tr><td><b>CHOOSE ID TO CHECK BY</b></td></tr><tr><td><center><select name = 'cuba'>";
	 while($checkby = mysql_fetch_array($sql2))
	{
	 echo "<option value ='".$checkby['ID']."'>".$checkby['ID']."</option>";	  
	}
	echo "</select></center></td></tr>";
	echo "<tr><td><center><input type='submit' name='submit' value='Check'></center></td></tr></table></form>";  */
	  
	  echo "<center><h3><a href='adminselect.php'>BACK</a>       <a href='logout.php'>LOG OUT</a></h3></center>";
	} 
 
    else
    { 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript">
 function a()
{
  var x = document.select.branchcodename.value;

  if(x=="")
  {
   alert("Please choose branch location");
   return false;
  }
}
</script>
</head>
<body bgcolor="#F5D16A">
<center>
<img src="OK.gif" />
<table border="0" align="center">
<form name="select" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" onsubmit="return a()">
<tr><td><center><h1>CHOOSE COUNTER CASH CHECKING REPORT LOCATION</h1></center></td></tr>
<tr><td><center>Branch Codename:<select name="tempat">
                                <option value="OK01">OK</option>
                                <option value="TK02">TK</option>
                                </select></center></td></tr>
<tr><td><center><input type="submit" name="submit" value="Submit"></center></td></tr>

</form>
</table>
</center>
</body>
</html>
<?php  

 }

	// $sql3 = mysql_query("UPDATE counter_cash SET Check_By ='$a' WHERE Check_By ='' ");  
	// $sql4 = mysql_query("UPDATE counter_cash2 SET Check_By ='$a' WHERE Check_By ='' "); 

 ?>
 
 

My screenshot is

 

 

76269170285222192319.jpg

 

 

It is possible when i click check symbol it update the check by name? how it update to check by name when clicking button on check symbol?

 

The check by name I took after the login Session and the update query in countercashadmineditcheckby2.php

<?php
session_start();
if (empty($_SESSION['is_logged_in']))
{
 header("Location:login.php");
 die();     // just to make sure no scripts execute
}
?>
<?php
 	mysql_connect("localhost","root") or die(mysql_error());
    mysql_select_db("kime") or die(mysql_error());
	$a=$_SESSION['branchcodename'];
	$b=$_SESSION['tempat'];
	if (isset($_POST["Check"]))
    { 
	 $b=$_SESSION['tempat'];
     $checkby=$_POST['cuba'];
	 $sql1 = mysql_query("UPDATE counter_cash SET Check_By = '$a'") or die(mysql_error());
	 $_SESSION['is_logged_in'] = 1;
	 if($_SESSION['is_logged_in'] == 1)
	 {
	   header("Location: countercashadminviewedit2.php");	 
	 }
	}
?>

I confusing how to send data from countercashadminlocation to countercashadmineditcheckby2.php because as I know if using dropdown it will send base on select name but about button I was confused, hope someobody can help me 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.