Richa Sharma
Richa Sharma

Reputation: 73

Update two columns in a query

I have one php website in which when press one action button called Activate...

I am changing value of column from 0 to 1 with query. I want also change time stamp from other column qu_time with current time stamp.

My query is like below

$upd_qry = "update tbl_quotes 
            set qu_status='".$_GET['status']."' 
            where id='".$_GET['quotes_id']."'";

What should I do for update column qu_time with current time stamp ?

Thanks

Upvotes: 0

Views: 59

Answers (3)

Muhammad Muazzam
Muhammad Muazzam

Reputation: 2800

You should use date()

"update tbl_quotes set qu_status='".$_GET['status'].",qu_time=date('Y-m-d H:i:s') where id='".$_GET['quotes_id']."'";

Upvotes: 0

Jerodev
Jerodev

Reputation: 33186

You can use a comma(,) to update multiple fields in an SQL query. Also, to get the current timestamp, you can use the SQL function NOW().

Combine these and you can do something like this:

$upd_qry = "update tbl_quotes 
    set qu_status='".$_GET['status']."', qu_time=NOW()              
    where id='".$_GET['quotes_id']."'";

Upvotes: 2

Sagar Gangwal
Sagar Gangwal

Reputation: 7937

"update tbl_quotes set qu_status='".$_GET['status']."',qu_time=sysdate() where id='".$_GET['quotes_id']."'";

Try above code.

hope this will helps.

Upvotes: 1

Related Questions