Hi everyone. I'm new in php and need someone to help my problem.

I have one table name data_transaction, from this table i'm want to search data between two dates that user key in.

Here my code,

$sum = "SELECT * , SUM(trans_charges) FROM data_transaction WHERE Location = 'HA1' AND Description = 'FINANCE' AND date_visit = '$date_start' AND date_visit = '$date_end'" ;

the problem is, i want to display summation of the trans_charges between the above condition.

it display all the summation,without filter the date that user key in

thanks..

Assuming that date_visit is of date or datetime type you can use the BETWEEN operator in mysql.

... WHERE date_visit BETWEEN '$date_start' AND '$date_end' ...

it's doesn't work. can't display anything

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.