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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:24:05+00:00 2026-06-13T14:24:05+00:00

Right, so I have an array in one table in my database. I need

  • 0

Right, so I have an array in one table in my database. I need to break this array apart so I can use one bit of it to get information from another table in my database and then send an email with that information in.

My array in the table looks like this

30-1,

30 is the product ID and 1 is the quantity. (Quantity of item purchased)

Have I been a muppet and got this wrong?

//Get product_id_array of item purchased
$sql = mysql_query("SELECT product_id_array FROM transactions WHERE id='$orderID'")or die(mysql_error());
while($row = mysql_fetch_array($sql)){
    $prod_quant_array = $row['product_id_array'];
}
//Explode prod_quant_array
(explode("-", $prod_quant_array));
$product_id = $prod_quant_array[0];
$product_quantity = $prod_quant_array[1];

I thought that this would then give me two variables.
$product_id would be 30 and $product_quantity would 1

I’m then trying to use this information to get more information from another table.

$sql = mysql_query("SELECT product_name, product_price FROM products WHERE id='$product_id'")or die(mysql_error());
while($row = mysql_fetch_array($sql)){
    $product_name = $row['product_name'];
    $product_price = $row['product_price'];
}

As you can see, my WHERE is looking at the $product_id variable.
So when I try and send the email, I get the email, but I can’t see the $product_name or $product_price. Please ignore those other variables, they are displaying fine in the email and are coming from a different query.

/////// Send Email ///////
$to = "" . $payer_email . "";
$subject = "Confirmation of your order";
$message .= "Dear " . $first_name . " " . $last_name . ",

This is an email to confirm your recent purchase of goods with Bloodlust.

You have ordered: 

--------------------------------------------------
" . $product_name . ".

" . $product_price . "
--------------------------------------------------

Please keep this email for your records.

Please note that this is not a proof of transaction.

Thank you.";
$from = "no-reply@blood-lust.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);

Is my explode() ?
Or is it something else?

This is absolutely killing my brain, I’ve been at it for hours. Please help! 🙂

  • 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-13T14:24:06+00:00Added an answer on June 13, 2026 at 2:24 pm

    Try $prod_quant_array = explode("-", $prod_quant_array);

    And as a side note you should really normalize your database by adding a quantity field and have the current field only hold the product id. That way you can also join the product price in the same query, rather than sending another one.

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

Sidebar

Related Questions

I have this code right here, where the $friends variable is an array with
Right now, I have this code where $obj_arr maybe contain array and an object.
I hope I can explain this right I have two input fields that require
I need to create module in Magento which will have few database tables. One
I have a database table with a large number of rows and one numeric
Right now I have def min(array,starting,ending) minimum = starting for i in starting+1 ..ending
This is what I have right now for a file residing on the same
I have an in-memory table that might looks something like this: Favorite# Name Profession
I currently have a database of 'school' entities and 'name' entities. [School <---- (one
I have an array $eps coming from MYSQL table and I want to output

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.