Hi all,

I want to approve records in my page. For that i have created a search where data retrieves based on account_number. Now i want to approve records. For that i have created a page called approve_page.php. But it seems to be applied for all the data. I just want to approve ONLY one record at a given time.(one by one)

<?php
   
$connect=mysql_connect('localhost','root','');
mysql_select_db('bank',$connect);

$account_number=$_POST['account_number'];

   $query = "select * from transaction WHERE account_number='$account_number'";
   mysql_query($query) or die(mysql_error());
   
   $query = "UPDATE transaction SET approved_status='1'
   WHERE account_number='$account_number'";
   $result = mysql_query($query) or die(mysql_error());

   if ($result)
   {
      echo "Details have been successfully approved";
   }
   
?>

I understand very little what you need. But this line is just an extra in this source:

$query = "select * from transaction WHERE account_number='$account_number'";
   mysql_query($query) or die(mysql_error());

Yeah.thanks for pointing out. it is my mistake....But how am i approve records one by one..

If i elaborate more, when a user enter an account number and click on search button the respective data retrieve from the database as a form. Then user has to click on "Approve" button to approve data.Above i posted the code which links to "Approve" button.

transaction (tran_id, account_number, tran_type, tran_amount, tran_date, approved_status(default=0))

This generates an error "Undefined variable: account_number"

You can do that by using a primary key attribute and for every transaction generate the key and then use this query:-
Let the primary key be-"Trans_id"
Then:-

$query = "UPDATE transaction SET approved_status='1'
   WHERE account_number='$account_number' and Trans_id='$_POST['trans_id']";
   mysql_query($query) or die(mysql_error());

Now only the respective transaction for a user will be marked as approved...

Undefined variable: account_number means the value is not posted or you use wrong variable $_POST. Post your html code here. And instead of youe line 6 try this.

if(isset($_POST['account_number']))
    $account_number=$_POST['account_number'];
else
    $account_number='';

Thanks a lot. Both are working....:)

mark the thread as solved if your problem is solved...

Just another small issue...When a user want to modify customer details before approval, i created a page and following error occurs.

Customer details Column 'account_number' in where clause is ambiguous

if(isset($_POST['account_number']))
    $nic=$_POST['account_number'];
else
    $account_number='';
	
$sql =sprintf("SELECT account_details. nic,full_name,phone_number,address,gender,date_of_birth,account.name_with_initials,account_type,fd_period"." FROM account_details,account"." WHERE `account_number`='%s'", mysql_real_escape_string($_POST['account_number']) );
;

$result=mysql_query($sql) or die( mysql_error() );

  if( mysql_num_rows($result)==0 )
  {
    echo "<p>No records found.</p>";
  }	
				 
				 
                 	   
$query ="SELECT account_details. full_name,phone_number,address,gender,date_of_birth,account.name_with_initials,account_type,fd_period"." FROM account_details,account"." WHERE account_details.account_number=account.account_number";

$result = mysql_query($query) or die(mysql_error());
while ($row=mysql_fetch_array($result)){
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.