Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: joeyjoe on August 23, 2011, 04:16:14 PM



Title: PHP - Display all transactions to address
Post by: joeyjoe on August 23, 2011, 04:16:14 PM
Im just trying to display all the transactions in a table that were sent to the account called "1"

just like bitcoinduit does it:

http://bitcoinduit.com/Klondike_Gold_Rush


Title: Re: PHP - Display all transactions to address
Post by: vv01f on August 23, 2011, 06:24:13 PM
We now know what you wanna achieve, but we cannot exactly know which ways you have been going already to implement btc with your php-host.
Probably you can post some more information how you connect to daemon and if you get any other information from it already or you still lack the connection..

but if you simply are interested, the wiki gives - at least for my contiguous - enough info: https://en.bitcoin.it/wiki/API_reference_(JSON-RPC)#PHP

the method to call is listreceivedbyaccount or listreceivedbyaddress (as you know the exact address when you know the acc) as you can read here: https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_Calls_list#Full_list


Title: Re: PHP - Display all transactions to address
Post by: joeyjoe on August 24, 2011, 12:32:20 PM
Thanks. I managed to work out how to do it. The problem i had is that it would output it in raw data, but i needed to output into an array. a simple bit of php code i was overlooking.

I have managed to do this now, but confused as to why i cannot list the senders address with the transactions


Title: Re: PHP - Display all transactions to address
Post by: Anonymous on August 28, 2011, 01:13:14 AM
Im just trying to display all the transactions in a table that were sent to the account called "1"

just like bitcoinduit does it:

http://bitcoinduit.com/Klondike_Gold_Rush
Sorry, but this was too tempting. I wrote an entire script when I saw this problem and I have to show it off!
Code:
<?php
//Create $jsonRPCClient
$transactions $jsonRPCClient->listtransactions('1',100000000); // the 100000000000 is the max transactions listed. The default is ten, so we set this to a really high number to make sure we list as many transactions as we can
$info $jsonRPCClient->getInfo();
$fee $info["paytxfee"];
$table "<table id=\"transactions\"><tr><th>Txn ID</th><th>To Address</th><th>Value</th></tr>";
foreach (
$txn in $transactions) {
$id $txn["txid"];
$link "http://blockexplorer.com/tx/$id";
$id substr($id,5) . '...';
$address $txn["address"];
$value $txn["amount"]+($txn["amount"] < $fee 0);
$table .= "<tr><td><a href=\"$link\">$id</a></td><td>$address</td><td>$value</td></tr";
}
$table .= "</table>";
echo 
$table
?>

I can write an entire script that does styling and so on, with more detail, and other formatting for .5BTC if you want (if you don't have a script already)


Title: Re: PHP - Display all transactions to address
Post by: helloworld on August 28, 2011, 01:43:50 AM
There is a typo in the above code:

$jsonRPCClient->listtsansactions(


Title: Re: PHP - Display all transactions to address
Post by: Anonymous on August 28, 2011, 03:13:24 AM
There is a typo in the above code:

$jsonRPCClient->listtsansactions(


Thanks, fixed


Title: Re: PHP - Display all transactions to address
Post by: joeyjoe on August 28, 2011, 03:24:29 AM
Thanks for your input, i managed to do everything i needed. www.interbitlotto.com - I do do PHP just not with bitcoin, but pretty much figured it out now :)

thanks anyway