Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8696023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:10:51+00:00 2026-06-13T01:10:51+00:00

Customer table /////////////////////////////////////////////////////////// | id[PR] | name | email | | 10 | fabio

  • 0

Customer table

///////////////////////////////////////////////////////////
|      id[PR]  |      name        |       email           |  
|      10      |      fabio       |     fab@fab.com       |   
|      11      |      james       |     james@james.com   |   

Order table

//////////////////////////////////////////////////////////////////
|  order_id[PR]  |  ship_to[FK]  |  bill_to[FK]   | customer[FK] |  product, total, etc
|      251       |       3       |         2      |       10     |  . . . 

Ship to table

//////////////////////////////////////////////////////////////////////
|   customer[FK]  |  ship_to[PR]  |   label   |    address           |  city, state, zip, etc
|       10        |      3        |   office  |  123 main st         |  . . .
|       10        |      1        |   home    |  85 some place st    |  . . .

Bill to table

///////////////////////////////////////////////////////////////////////////
|   customer[FK]  |  bill_to[PR]  |   label   |    account                |  billing details
|       10        |      2        |   visa    |  AES_CRYPT(temp storage)  |   . . .
|       10        |      1        |     mc    |  AES_CRYPT(temp storage)  |   . . .

Ok so each customer can have multi-ship to addresses and multi-payment methods on file in their account. When they place an order the order table stores the cart and session information.

I need to generate invoices how do I structure my query so that when i lookup the order table i can see the row of ship to table and the row of bill to table instead of the id of the row in the associated table.

Now mind you i don’t expect anyone to write my code but if you can please give me some links to read up on that would be great or an example would be awesome. Please note im building on codeigniter so im using the MVC pattern.

? – Should all of these lookups be structured in 1 model function or should they be spread over several functions in the model?

return $this->db->get('order_table')->result();
#this would return all the orders in the order table . 

in my view i would foreach these results and make the order-id a link to more details/ invoice page. How do i pass the values from the row to the model query to generate the proper details/invoice page?

E.g. – So if you click on order 251, you will see a details page with an invoice that will say

  1. customer id 10
  2. name: fabio
  3. email: fab@fab.com
  4. ship to: office, 123 main st…
  5. bill to: visa, acct#, etc…
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T01:10:52+00:00Added an answer on June 13, 2026 at 1:10 am
    $this->db->join('customerTable','customerTable.id = orderTable.customer');
    $this->db->join('shipToTable', 'orderTable.ship_to = shipToTable.ship_to');
    $this->db->join('billToTable', 'billToTable.bill_to = orderTable.bill_to');
    $this->db->where('order_id', $orderId);
    $result = $this->db->get('order_table');
    if($result->num_rows()==1)
    {
        return $result->result_array();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a 'customers' table. Each record contains a customer name, email, address, etc.
Lets say i have a table with the following data Customer table: Name amount
I have a customer table where I'm currently storing: Last Name First Name Middle
I created a simple mysql database table using following query: CREATE TABLE customer( name
i have a table with columns cid (customer id) cemail (customer email) cfax (customer
I have three tables in mysql (localhost): customer , comprising columns (id,name,email,create_date,status) ; sell
I have a table customer that stores a customer_id, email and reference. There is
I have the following two tables: Customer { int Id int Name } Bills
Let's say I have a Customer table which has a PrimaryContactId field and a
Say I have a typical customer table; Id Int Identity Primary Key, FirstName varchar(255),

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.