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

  • SEARCH
  • Home
  • 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 8225641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:28:52+00:00 2026-06-07T15:28:52+00:00

I have a database with a transaction field, this displays products brought on my

  • 0

I have a database with a transaction field, this displays products brought on my website. I am trying to develop an admin interface where i can see the products brought.

The string looks like this
37,2:27,1:5,3:94,10:49,15:

This basically means that the customer ordered product ID number 37 with the quantity of 2. Included in their transacvtion was product id 27 with qty 1 and so on.

product_id,ordered_quantity:nextproduct_id,next_orderedquantity.

In order to display this information I need to break this down. I have tried php explode but having some trouble. So we need to split the product on colon : and the qty and id by comma. The string can be one product or many.

Anyone got any suggestions?

  • 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-07T15:28:54+00:00Added an answer on June 7, 2026 at 3:28 pm
    $ids = '37,2:27,1:5,3:94,10:49,15';
    $products = explode(':', $ids);
    $productAndQuantity = array();
    foreach ($products as $product) {
        $exploded = explode(',', $product);
        $productAndQuantity[$exploded[0]] = $exploded[1];
    }
    

    You get a profuct id – quantity array.

    This way of storing data is non-scalable and error-prone. Why not use a table with the following fields: userId, productId, quantity?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have Database with date field. I see the time like: 1900-01-01 13:38:00.000 How
I have a Django database of books, with attached transactions. In the admin interface,
I have two database tables, subscription and transaction , where one subscription can have
i have database table like this +-------+--------------+----------+ | id | ip | date |
I am trying to rename a field in my database through SQLite.net and am
I have a database table with a unique string field and a couple of
I have a sql exception from clojure that goes like this: java.lang.Exception: transaction rolled
I have one table called: Transaction. This table has the following fields: (ID,ProductName,Amount,Date) placed
I have a vector<set<char> > data structure (transactions database) and I want to know
I have database with multiple tables in Microsoft SQL Server with schema in tables

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.