Directly you can't access block data for x transaction in solidity, but below block info you can access in solidity.
block.blockhash(uint blockNumber) returns (bytes32): hash of the given block number - Its only works for 256 most recent blocks
block.coinbase (address): current block miner address
block.difficulty (uint): current block difficulty
block.gaslimit (uint): current block gaslimit
block.number (uint): current block number
block.timestamp (uint): current block timestamp
Save above variables in solidity then use oraclize service or generate an event use clients to listen an events. From there you can read block inputs and push back to your contract.
More details refer below link