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 4040872
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:48:28+00:00 2026-05-20T12:48:28+00:00

here is my array Array ( [0] => 31 [1] => 36 [2] =>

  • 0

here is my array

Array
(
    [0] => 31
    [1] => 36
    [2] => 41
)

the 31,36, and 41 are id’s of a record. the elements in this array can be from anywhere of 1 element to 10+ elements. the table structure looks something like this (shortened-version)

tbl_cart
---------
id (auto-incremented)
product_name
price

what i’m trying to figure out is how can i do a query that will grab the id’s listen in a dynamically created array then accumulate the price for each respected id and display the output?

thanks, let me know if this doesnt make sense.

  • 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-05-20T12:48:29+00:00Added an answer on May 20, 2026 at 12:48 pm

    you want to sum the prices for the ids in your list right?

    $idStr = implode(',', $arr);
    $sql = "SELECT sum(price) FROM tbl_cart WHERE id in ($idStr)";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating forms elements like this: $element = $this->CreateElement('select', 'countries'); $element->setLabel('Countries'); $element->setAttrib( 'required',
Here's my query, in CodeIgniter's Active Record: function calculate_invites($userid) { $this->db->where('id', $userid) ->update('users', array('invites'
I need to build a multidimensional array from records retrieved from my database. Here
I have to parse xml files that look like this : http://goo.gl/QQirq How can
I have a column chart in Highcharts that looks roughly like this: | |
here is my xml: <record> <id>12342</id> <name>xx</name> <blah1>asdfas</blah1> <blah2>asdfas</blah2> ..... </record> I would like
Here is the table in which ia am retrieving the data from sqlite,, at
There is only one record in the table so why does it loop like
So i have a class name repository which is just a simple array.Here is
if($err) $_SESSION['msg']['login-err'] = implode('<br />',$err); Three quick questions: Why use a two-dimensional array here?

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.