hi jsphlane20;
First of all thank you very much for spending some time to help me.I have tried what you have sent. but its not working. its not updating. when i used this code, i cannot enter values into the data base too.
<?php
echo "<h2> transaction description </h2>";
echo "<hr>";
//Connection to the data base.
$connect = mysql_connect ("localhost","root","") or die ("error");
mysql_select_db ("guestbook") or die ("eroor connecting Database");
$queryget = mysql_query ("select * from report ORDER BY Transaction_Number DESC LIMIT 5" ) or die (" error with table");
//this while loop will get the information from the data base and it will be displayed on the web interface.
echo "<hr>";
while ( $row = mysql_fetch_assoc ($queryget) ){
$id = $row['id'];
$Customername = $row ['Customer_name'];
$Transaction_Number = $row ['Transaction_Number'];
$Price = $row ['Price'];
$Weight = $row ['Weight'];
$date = $row ['Date'];
$time = $row ['Time'];
echo"
<table>
<tr>
<td>
<b> Customer name : $Customername</b>
</td>
</tr>
<tr>
<td>
<b> Weight : $Weight</b>
<p>
<input type='hidden' name='id' value='$id'>
<input type='submit' name='submit2' value='Void'>
</td>
</tr>
";
echo "<hr>";
}
// to get the summation of the parameter weight.
$query = "SELECT SUM(Weight) FROM report ";
$result = mysql_query($query) or die(mysql_error());
// Print out result
while($row = mysql_fetch_array($result)){
echo "Total ". $row['SUM(Weight)'];
echo "<br />";
}
// this will post the input data into the data base.
if (isset($_POST['submit1']))
{
$Customername = $_POST['Customer_name'];
$Transaction_Number = $_POST['Transaction_Number'];
$Price = $_POST['Price'];
$Weight = $_POST['Weight'];
$date = date("Y-m-d");
$time = date("H:i:s");
$status = 'Completed'; // this is to indicate that the transaction has done.
if ($Customername&&$Transaction_Number&&$Price&&$Weight )
{
$querypost = mysql_query (" INSERT INTO report VALUES ('',$Customername', '$Transaction_Number', '$Price', '$Weight','$date','$time','$status')");
echo "Please wait... <meta http-equiv='refresh' content='4'>";
}
else
echo " fill out all fileds";
}
// when the operator clicked the void button on the web interface,that perticular transaction has to be marked as cancel.this part is not working for it.
if (isset($POST['submit2']))
{
if(isset($_POST['id']))
{
$id = $_POST['id'];
}
$query = "UPDATE report SET Status = 'Cancel' WHERE id = $row ['id']";
mysql_query($query) or die('Updating process is not sucessfull');
}
echo"
<form action='guestbook.php' method='POST'>
<table width= '100 %'>
<tr>
<td>
Customer name
</td>
<td>
<input type='text' name='Customer_name' maxlength='30'>
</td>
</tr>
<tr>
<td>
Transaction Number
</td>
<td>
<input type='int' name='Transaction_Number' maxlength='25'>
</td>
</tr>
<tr>
<td>
Price
</td>
<td>
<input type='int' name='Price' maxlength='25'>
</td>
</tr>
<tr>
<td valign='top'>
Weight
<td>
<input type='int' name='Weight' maxlength='25'>
<p>
<input type='submit' name='submit1' value='Confirm'>
</td>
</tr>
</table>
</form>
"
?>
Jsphlane20 wrote:Shehan31,
I think I have an understanding of what you are trying to accomplish. If the operator selects the void button you would like to update that record with the status of “Canceled”. I think there are several ways to accomplish this. One way you can do this is by first adding an extra field in your 'report' table named “id” and set it to auto-increment. That will give every record in your customer database a unique id upon creation. If you are now familiar with how this works, please search for tutorials on youtube.
You could then do something similar.
-----------------------INFO THAT IS DISPLAYED
<
Code: Select all
?php
echo "<h2> transaction description </h2>";
echo "<hr>";
//Connection to the data base.
$connect = mysql_connect ("localhost","root","") or die ("error");
mysql_select_db ("guestbook") or die ("eroor connecting Database");
$queryget = mysql_query ("select * from report ORDER BY Transaction_Number DESC LIMIT 5" ) or die (" error with table");
//this while loop will get the information from the data base and it will be displayed on the web interface.
echo "<hr>";
while ( $row = mysql_fetch_assoc ($queryget) ){
$id = $row['id']; //puls in the unique id for this customer.
$Customername = $row ['Customer_name'];
$Transaction_Number = $row ['Transaction_Number'];
$Price = $row ['Price'];
$Weight = $row ['Weight'];
$date = $row ['Date'];
$time = $row ['Time'];
echo"
<table>
<tr>
<td>
<b> Customer name : $Customername</b>
</td>
</tr>
<tr>
<td>
<b> Weight : $Weight</b>
<p>
<input type='hidden' name='id' value='$id'>
<input type='submit' name='submit2' value='Void'>
</td>
</tr>
";
?>
-----------------------CODE TO UPDATE THE RECORD
Code: Select all
<?php
if (isset($_POST['submit2']))
{
if(isset($_POST['id'])
{
$id = $_POST['id'];
}
$query = "UPDATE report SET Status = 'Cancel' WHERE id = '$id';";
mysql_query($query) or die('Updating process is not sucessfull');
}
?>
I haven't tested this exact code but you should be able to adjust as necessary. Please reply confirming your understanding.
hi jasphlane 20;
it does not work with and the status will not be changed. when i use this code i cant enter values in to the data base by the web interface.
<?php
echo "<h2> transaction description </h2>";
echo "<hr>";
//Connection to the data base.
$connect = mysql_connect ("localhost","root","") or die ("error");
mysql_select_db ("guestbook") or die ("eroor connecting Database");
$queryget = mysql_query ("select * from report ORDER BY Transaction_Number DESC LIMIT 5" ) or die (" error with table");
//this while loop will get the information from the data base and it will be displayed on the web interface.
echo "<hr>";
while ( $row = mysql_fetch_assoc ($queryget) ){
$id = $row['id'];
$Customername = $row ['Customer_name'];
$Transaction_Number = $row ['Transaction_Number'];
$Price = $row ['Price'];
$Weight = $row ['Weight'];
$date = $row ['Date'];
$time = $row ['Time'];
echo"
<table>
<tr>
<td>
<b> Customer name : $Customername</b>
</td>
</tr>
<tr>
<td>
<b> Weight : $Weight</b>
<p>
<input type='hidden' name='id' value='$id'>
<input type='submit' name='submit2' value='Void'>
</td>
</tr>
";
echo "<hr>";
}
// to get the summation of the parameter weight.
$query = "SELECT SUM(Weight) FROM report ";
$result = mysql_query($query) or die(mysql_error());
// Print out result
while($row = mysql_fetch_array($result)){
echo "Total ". $row['SUM(Weight)'];
echo "<br />";
}
// this will post the input data into the data base.
if (isset($_POST['submit1']))
{
$Customername = $_POST['Customer_name'];
$Transaction_Number = $_POST['Transaction_Number'];
$Price = $_POST['Price'];
$Weight = $_POST['Weight'];
$date = date("Y-m-d");
$time = date("H:i:s");
$status = 'Completed'; // this is to indicate that the transaction has done.
if ($Customername&&$Transaction_Number&&$Price&&$Weight )
{
$querypost = mysql_query (" INSERT INTO report VALUES ('',$Customername', '$Transaction_Number', '$Price', '$Weight','$date','$time','$status')");
echo "Please wait... <meta http-equiv='refresh' content='4'>";
}
else
echo " fill out all fileds";
}
// when the operator clicked the void button on the web interface,that perticular transaction has to be marked as cancel.this part is not working for it.
if (isset($POST['submit2']))
{
if(isset($_POST['id']))
{
$id = $_POST['id'];
}
$query = "UPDATE report SET Status = 'Cancel' WHERE id = $row ['id']";
mysql_query($query) or die('Updating process is not sucessfull');
}
Jsphlane20 wrote:Shehan31,
I think I have an understanding of what you are trying to accomplish. If the operator selects the void button you would like to update that record with the status of “Canceled”. I think there are several ways to accomplish this. One way you can do this is by first adding an extra field in your 'report' table named “id” and set it to auto-increment. That will give every record in your customer database a unique id upon creation. If you are now familiar with how this works, please search for tutorials on youtube.
You could then do something similar.
-----------------------INFO THAT IS DISPLAYED
<
Code: Select all
?php
echo "<h2> transaction description </h2>";
echo "<hr>";
//Connection to the data base.
$connect = mysql_connect ("localhost","root","") or die ("error");
mysql_select_db ("guestbook") or die ("eroor connecting Database");
$queryget = mysql_query ("select * from report ORDER BY Transaction_Number DESC LIMIT 5" ) or die (" error with table");
//this while loop will get the information from the data base and it will be displayed on the web interface.
echo "<hr>";
while ( $row = mysql_fetch_assoc ($queryget) ){
$id = $row['id']; //puls in the unique id for this customer.
$Customername = $row ['Customer_name'];
$Transaction_Number = $row ['Transaction_Number'];
$Price = $row ['Price'];
$Weight = $row ['Weight'];
$date = $row ['Date'];
$time = $row ['Time'];
echo"
<table>
<tr>
<td>
<b> Customer name : $Customername</b>
</td>
</tr>
<tr>
<td>
<b> Weight : $Weight</b>
<p>
<input type='hidden' name='id' value='$id'>
<input type='submit' name='submit2' value='Void'>
</td>
</tr>
";
?>
-----------------------CODE TO UPDATE THE RECORD
Code: Select all
<?php
if (isset($_POST['submit2']))
{
if(isset($_POST['id'])
{
$id = $_POST['id'];
}
$query = "UPDATE report SET Status = 'Cancel' WHERE id = '$id';";
mysql_query($query) or die('Updating process is not sucessfull');
}
?>
I haven't tested this exact code but you should be able to adjust as necessary. Please reply confirming your understanding.
echo"
<form action='guestbook.php' method='POST'>
<table width= '100 %'>
<tr>
<td>
Customer name
</td>
<td>
<input type='text' name='Customer_name' maxlength='30'>
</td>
</tr>
<tr>
<td>
Transaction Number
</td>
<td>
<input type='int' name='Transaction_Number' maxlength='25'>
</td>
</tr>
<tr>
<td>
Price
</td>
<td>
<input type='int' name='Price' maxlength='25'>
</td>
</tr>
<tr>
<td valign='top'>
Weight
<td>
<input type='int' name='Weight' maxlength='25'>
<p>
<input type='submit' name='submit1' value='Confirm'>
</td>
</tr>
</table>
</form>
"
?>