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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T05:31:33+00:00 2026-05-19T05:31:33+00:00

I am working on my web site and I am trying to implement a

  • 0

I am working on my web site and I am trying to implement a feature that works like this:

Admin checks a checkbox on a record to show that payment is received. The values are stored in an array called $paymentr which is imploded and updates the MySQL database.

Now here’s where the tricky part (for me, anyway) comes in:

After it does this, the code checks how many rows have been affected and then sends out ONE email to another person that should list all the information for the records based on the IDs stored in the array.

For some reason I’ve been having a bear of a time trying to figure out how to do this. I had a foreach loop running right before the email code which ran something like this (I have simplified the query as it is much longer and complex, but I HAVE tested it in phpmyadmin) —

foreach ($paymentr as $v) {

$query = "SELECT transactions.id, transactions.refid, transactions.affid FROM transactions WHERE transactions.id = '$v'";

$result = mysql_query($query) or die("Query Failed: ".mysql_errno()." - ".mysql_error()."<BR>\n$query<BR>\n");
$trans = mysql_fetch_array($result, MYSQL_ASSOC);

$transactions .= '<br>User ID:'.$trans['id'].' -- '.$trans['refid'].' -- '.$trans['affid'].'';

}

Then that $transactions variable would be sent out in the email code.

But it didn’t work, sadly. Does anyone have any ideas? I feel like I am just missing one crucial chunk or idea… anything would be helpful. Maybe array_map? I’ve never used that though. Thank you ever so much 🙂

  • 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-19T05:31:34+00:00Added an answer on May 19, 2026 at 5:31 am

    I tried your code and didn’t notice anything wrong. To help debug, you could try adding some “print_r” and “echo” code for a better sense of what’s happending

    Also, you mentioned that your array is imploded, which to my understanding returns a string with the values of the array in the form [value][separator][value]…, is it still an array when the ‘foreach’ starts? Are you finding that $transactions is empty?

    print_r ($paymentr);  // <-----  ADDED FOR DEBUG
    
    foreach ($paymentr as $v) {
    
    $query = "SELECT id, refid, affid FROM transactions WHERE id = '$v'";
    
    echo $query . "<br/>";  // <-----  ADDED FOR DEBUG,  (XHTML <br/> closed tag)
    
    $result = mysql_query($query) or die("Query Failed: ".mysql_errno()." - ".mysql_error()."<BR>\n$query<BR>\n");
    $trans = mysql_fetch_array($result, MYSQL_ASSOC);
    
    $transactions .= '<br>User ID:'.$trans['id'].' -- '.$trans['refid'].' -- '.$trans['affid'].'';    
    }
    

    Or, you could do this, which hits the db less:

    foreach ($paymentr as $v) { $in_clause .= "'".$v."',"; }
    $in_clause = trim($in_clause, ",");
    $query = "SELECT id, refid, affid FROM transactions WHERE id IN ($in_clause)";
    
    $result = mysql_query($query) or die("Query Failed: ".mysql_errno()." - ".mysql_error()."<BR>\n$query<BR>\n");
    while ( $trans = mysql_fetch_array ( $result, MYSQL_ASSOC ))    
    {
      $transactions .= '<br>User ID:'.$trans['id'].' -- '.$trans['refid'].' -- '.$trans['affid'].'';
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.