For Connecting to database, create a PHP file name dbsettings.php with following code :
Data query :
Suppose you have a table name billings which has coloumn trans_id, amount and so on.
Create a another file name dataquery.php with following code:
$query="select * from billings where trans_id='2013' ";
echo "Transaction ID. 2013 amount is Rs.".$rows['amount'];