Welcome Guest, Not a member yet? Register   Sign In
Best way to display data in a table matrix..??
#1

[eluser]angelleye[/eluser]
I'm trying to create a table to compare the rates for a variety of different merchant account providers. I've attached a sample of what this table should look like, but it's all static, bogus data.

I've got a single table in my db called merchant_account_providers that holds the name and all of the rate details for providers. I've attached another image of the design view of this table. You can see that I basically have a field for each row in the table sample, but that's where I get a little confused on how to output this.

In most cases, I grab data from a db and simply output it all as rows with maybe a static header. In this case, I'd actually be outputting all of the records as columns instead of rows.

What's the best way to output data in a table like this? I started playing with hit a little bit but I'm just not sure I'm going in the right direction.

I have a model with the following function...

Code:
public function get_merchant_account_provider_rate_data($merchant_provider_id = '')
{
  $rate_data = $this->db->get_where('merchant_account_providers',array('id'=>$merchant_provider_id),1)->result_array();
  return $rate_data[0];
}

Then in my controller I find myself making multiple db selects to gather each provider's data independently and pass it all to the view separately in my controller...

public function index()
{
$this->load->model('pricing_meta_data_model');

$data['paypal_standard_rates'] = $this->pricing_meta_data_model->get_merchant_account_provider_rate_data(1);
$data['paypal_advanced_rates'] = $this->pricing_meta_data_model->get_merchant_account_provider_rate_data(2);
$data['paypal_pro_rates'] = $this->pricing_meta_data_model->get_merchant_account_provider_rate_data(3);
$data['authnet_rates'] = $this->pricing_meta_data_model->get_merchant_account_provider_rate_data(4);
$data['stripe_rates'] = $this->pricing_meta_data_model->get_merchant_account_provider_rate_data(5);
$data['braintree_rates'] = $this->pricing_meta_data_model->get_merchant_account_provider_rate_data(6);
$data['wepay_rates'] = $this->pricing_meta_data_model->get_merchant_account_provider_rate_data(7);
$data['square_rates'] = $this->pricing_meta_data_model->get_merchant_account_provider_rate_data(8);
$data['firstdata_rates'] = $this->pricing_meta_data_model->get_merchant_account_provider_rate_data(9);
$data['paysimple_rates'] = $this->pricing_meta_data_model->get_merchant_account_provider_rate_data(10);
$data['dwolla_rates'] = $this->pricing_meta_data_model->get_merchant_account_provider_rate_data(11);

$data['page_name'] = 'pricing_meta_data';
$this->load->view('dashboard/layout/master',$data);
}
[/code]

Then in my view I'm able to use grab specific data. For example, $paypal_standard_rates['transaction_base_fee_percentage_amex'].

This is working, but it doesn't seem very dynamic. I feel like I'm making a mistake going this route. If I want to let somebody choose 2, 3, 5, etc. providers to compare when looking at this table, how would I do that?

I could send the ID's of each provider to my controller and then make these same db selects with a dynamic ID being passed, I know, but then matching up all of that data correctly in the columns and rows is throwing me for a loop.

I know this sort of more a general PHP question than a CI specific question, but I wanted to make sure there wasn't some magic data grid or something that was part of CI and could help me out here.

Any information on this would be greatly appreciated. Thanks!




Theme © iAndrew 2016 - Forum software by © MyBB