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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:48:10+00:00 2026-05-30T06:48:10+00:00

I am querying the database for different values of prizes for an online loyalty

  • 0

I am querying the database for different values of prizes for an online loyalty scheme.

I know this is going to be a sort of easy question but Im still getting used to PHP so here goes…

This is what I have so far:

 <?php $sqlprize="SELECT prizeid FROM wp_scloyalty_orders WHERE  userid = '$user_id'";

            $resultprize=mysql_query($sqlprize); ?>

            <?php while($rows=mysql_fetch_array($resultprize)){  

                    query_posts('post_type=prizes&showposts=-1&p='.$rows['prizeid'].''); while (have_posts()) : the_post(); 
                    $my_meta = get_post_meta($post->ID,'_my_meta',TRUE);


                        //echo $my_meta['pointsvalue'];

                    endwhile; 
                    wp_reset_query();  



             } ?>

Basically I want it so each time it loops the database query it adds the value (my_meta[‘pointsvalue’] to an array, which I can use outside of the loop…

Thanks!

EDIT—————–

               <?php $purchasevalue=array(); ?>

           <?php $sqlprize="SELECT prizeid FROM wp_scloyalty_orders WHERE  userid = '$user_id'";

            $resultprize=mysql_query($sqlprize); ?>

            <?php while($rows=mysql_fetch_array($resultprize)){  

                    query_posts('post_type=prizes&showposts=-1&p='.$rows['prizeid'].''); while (have_posts()) : the_post(); 
                    $my_meta = get_post_meta($post->ID,'_my_meta',TRUE);            

                        $purchasevalue[] = $my_meta['pointsvalue'];         
                    endwhile; 
                    wp_reset_query();  

             } ?>

             <?php echo array_sum($purchasevalue) ?>

Thanks guys, sorted it in the end… is this a good way of doing it?

  • 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-30T06:48:12+00:00Added an answer on May 30, 2026 at 6:48 am

    You can use array_push to add values to an array

    $array = array();
    
    while()....
       $my_meta = ....
       array_push($array, $my_meta);
    end while;
    
    //Your array is now
    print_r($array);
    

    Hope that’s what you’re looking for

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

Sidebar

Related Questions

When querying the database with the same query but different parameters, is it better
I know this question was asked several times, but as far as my search
i'm querying a database like this: SELECT * from Log WHERE cookieId IN (select
Question: I can get the SQL Server database language by querying: SELECT @@language And
This seems like a pretty simple question, but I have not managed to find
I have data in different tables but in the same database, all of which
I'm querying some products in SQLite database, but same base in 2 differents android's
I really don't know what's going on with my configuration, but I'm just not
I have some existing code that is querying a SQL database repeatedly with different
I'm querying the database for a single record that matches the id passed in

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.