简体   繁体   中英

Codeigniter mysql db query to display 3 rows of results on page using 2 tables on 3 joins

New to codeigniter and having trouble on a query for 2 tables. The first table "claims" is loaded into a page showing 3 of the 15 or so cells in the headings (as per claims.png), a method in the second method is then called to load site/claims/view_claim_det/$claim_id when user clicks the "view claim" link. which the new view by claim_id . The second table driver_detail has to load 2 rows (#1 is nonfault and #2 is atfault info ) through a query defined by nonfault claims.claim_driver_id1 = driver_detail.driver_id and atfault claims.claim_driver_id2 = driver_detail.driver_id (2 rows returned to display as per ClaimsDetail.png).

I have the claims table row loaded where the results fall mainly at the end of the page, I can't figure how to call the driver_detail table and run the 2 queries to then display the results required for each Nonfault and Atfault info.

I'm sure its something so easy, each time I think I have it I get plagued by php errors.

Any help would be amazing!!

claims view

claims_detail view

There are two things you can do in this case. Create 2 methods, one for each view: atfault and nonfault that would return their own sections individually. Then..

1,. You could use Ajax to display each sections separately. 2, if you need to provide an initial view then you could call these methods within your main method and pass the rendered sections as a variable to your view.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM