2

enter image description here

when I click on view button I just only see record of first customer how do I get particular id of particular customer please explain me in detail and I am using codegniter here is some of my code where I want to add ..

AdminController.php

<?php
class AdminController extends MY_Controller {
function __construct()
{
    parent::__construct();
    if(!$this->session->userdata("id")) {
        return redirect('logincontroller/index');
    }
}
public function dashboard()
{

   $this->load->view('admin/dashboard');
}
public function orderhistory()
{
    $this->load->view('admin/order_history');
}
public function catalogue()
{
    $this->load->view('admin/catalouge');
}
public function admin_detail()
{
    $this->load->view('admin/admin_detail');
}
public function agent_detail()
{
    $this->load->view('admin/agent');
}
public function customerdetail()
{
    $this->load->view('admin/customers');
}
public function paymenthistory()
{
    $this->load->view('admin/payment');
}
public function view_order_history()
{
    $this->load->view('admin/view_order_history');
}
public function edit_order_history()
{
    $this->load->view('admin/edit_order_history');
}
public function pagination($current_page)
{

}
public  function view_product_detail()
{
    $this->load->view('admin/view_product_detail');
}
public  function edit_product_detail()
{
    $this->load->view('admin/edit_product_detail');
}
public  function view_admin_detail()
{
    $this->load->view('admin/view_admin_detail');
}
public  function edit_admin_detail()
{
    $this->load->view('admin/edit_admin_detail');
}
public  function edit_agent_detail()
{
    $this->load->view('admin/edit_agent_detail');
}
public  function view_agent_detail()
{
    $this->load->view('admin/view_agent_detail');
}
public  function view_customer_detail()
{
    $this->load->view('admin/view_customer_detail');
}
public  function edit_customer_detail()
{
    $this->load->view('admin/edit_customer_detail');
}
public  function edit_payment_history()
{
    $this->load->view('admin/edit_payment_history');
}
public  function view_payment_history()
{
    $this->load->view('admin/view_payment_history');
}}?>

View_order_history

<div class="container">
    <div class="jumbotron">
        <h1>Jumbotron</h1>
        <p>This is a simple hero unit, a simple jumbotron-style component for  calling extra attention to featured content or information.</p>
        <p><a class="btn btn-primary btn-lg">Learn more</a></p>
    </div>
 </div>
Dhara
  • 1,914
  • 2
  • 18
  • 37
falak
  • 77
  • 1
  • 12
  • Sorry, is your problem stemming from the fact that `View` is only showing records from the first customer? –  Apr 27 '16 at 05:52
  • yes now i want to add api in my code and want to use in controller but data base api manage in controller not in model so how do i use code and get individual id – falak Apr 27 '16 at 05:56
  • Do you want to upload the entire site on to a [temporary file hosting](https://lefs.me/p/fh/) so I can take a look at the whole thing? –  Apr 27 '16 at 05:57
  • no tell me an other way to resolve this problem – falak Apr 27 '16 at 06:11
  • Okay, one way to resolve this problem would be to paste the contents of the PHP files linked in `AdminController.php` –  Apr 27 '16 at 06:13
  • http://api.amid.tech/alldata/0 here is api link now we just link this api but in controller how would i get indivisual id api fetch all data base data – falak Apr 27 '16 at 06:17
  • Sorry @falak, it's just really hard to fix a problem when we can't see the whole context of it. Is this site self-coded? If not, is there a link where we can see the site's original framework? –  Apr 27 '16 at 06:20

1 Answers1

0

Since you have no code relevant to what you are actually doing, here are some tips/ideas:

On your class, instead of making a bunch of methods that all do the same thing, I would suggest using __call() to overload the class and save yourself a ton of duplication. Normally I wouldn't suggest this, but in this case it makes sense:

class AdminController extends MY_Controller {
    {
        protected   $args;
        public  function __call($name,$args)
            {
                $count          =   (!empty($args));
                $this->args     =   ($count)? $args : false;
                $this->load->view("admin/{$name}");
            }
    }

To use, just call the name of the view action:

$tester =   new AdminController();
$tester->admin_detail();

When working with the form, you can make the buttons their own button with the id as a hidden field. I am just going to focus on the customer array on key [0] and subkey [0]. You, of course, would do a loop on the customer[0] array to get all rows:

<!-- tester.php is the page that you are sending the post to focus on.
I don't know what your actual page is called, you have not indicated
-->
<form action="/tester.php" method="post">
    <input type="text" name="id" value="<?php echo $arr['customer'][0][0]['id']; ?>" />
    <input type="submit" name="view" value="VIEW" />
    <input type="submit" name="delete" value="DELETE" />
    <input type="submit" name="edit" value="EDIT" />
<?php
foreach($arr['customer'][0][0] as $key => $value) {
    echo $value;
}
?>
</form>

When you click the VIEW button and post to the focus page, you are left with the row's id value which you can use your api to pull just that one (presumably you know how to get the API to do that?). Again you have no code posted to show how you do anything really, so this is just general. Here is what the button would produces. The id would change depending on which row you click on.

Array
(
    [id] => 1
    [view] => VIEW
)
Rasclatt
  • 12,498
  • 3
  • 25
  • 33