Code: Select all
<?php
echo"<h> Void a Transaction here </h>";
$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"
<form action='void.php' method='POST'>
<table width= '35 %' border = '3px'><blockquote></blockquote>
<tr>
<td>
<b> Customer name : $Customername</b>
</td>
</tr>
<tr>
<td>
<b> Weight : $Weight </b>
<p>
<input type='hidden' name='id' value= '$row [id]'/>
<input type='submit' name='submit' value='Void'/>
</td>
</tr>
</table>
</form>
";
}
// if the submit(void)) button is not clicked then the row id (called at the top of the code)will be set to an array.
if (!isset($_POST['submit']))
{
$q = "SELECT Status from report WHERE id = $row[id]";
$result = mysql_query($q);
$row = mysql_fetch_array($result);
}
//if the void button is clicked the status of the perticular record will be updated as cancel using the row id.
if (isset($_POST['submit'])){
$u = "UPDATE report SET Status = 'cancel' WHERE id = $row[id]";
mysql_query($u);
}
hi all :
I have been trying to update the table using the above system. the idea is only to change the status as cancel of the perticular record. I have posted this topic before but could not get a good reply. After that I have tried few other methods and faild. As a result I am posting it once again hoping I may get a better reply from a person who knows this subject better than me. I am reletivley new to this subject.
Thanking all
Shehan31