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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:51:20+00:00 2026-05-27T22:51:20+00:00

Hey guys i would like to repeat this statement 13 times by change this

  • 0

Hey guys i would like to repeat this statement 13 times by change this statement within a loop or something. "WHERE spending.SectorID = 1,2,3,4,5,6,7,8,9,10,11,12,13" how can i successfully do it without typing this code 12 more times. and i would to display the data individually though~ likewhere sectorid = 1; belong to a table with a button to initiate that particular query

<?php
$spendingname= array();
$spendingpercent = array();
$spendingid = array();

mysql_select_db($database_conn2, $conn2);
$query_Spending = "SELECT CONCAT(spending.SectorID, spending.ExpenditureID) AS 'SpendingID',
expenditure.ExpenditureName, spending.SpendingPercent, spending.SectorID
FROM spending   
INNER JOIN expenditure ON spending.ExpenditureID = expenditure.ExpenditureID
WHERE spending.SectorID = 1";
$Spending = mysql_query($query_Spending, $conn2) or die(mysql_error());
$totalRows_Spending = mysql_num_rows($Spending);
while($row_Spending = mysql_fetch_assoc($Spending))
{
$spendingname[] = $row_Spending['ExpenditureName'];
$spendingpercent[] = $row_Spending['SpendingPercent'];
$spendingid[]= $row_Spending['SpendingID'];
}
mysql_free_result($Spending);
?>
  • 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-27T22:51:21+00:00Added an answer on May 27, 2026 at 10:51 pm
        <?php
        $spendingname= array();
        $spendingpercent = array();
        $spendingid = array();
    
        mysql_select_db($database_conn2, $conn2);
        for($x=1;$x<14;$x++)
        {
        $query_Spending = "SELECT CONCAT(spending.SectorID, spending.ExpenditureID) AS 'SpendingID',
        expenditure.ExpenditureName, spending.SpendingPercent, spending.SectorID
        FROM spending   
        INNER JOIN expenditure ON spending.ExpenditureID = expenditure.ExpenditureID
        WHERE spending.SectorID = $x";
        $Spending = mysql_query($query_Spending, $conn2) or die(mysql_error());
        $totalRows_Spending = mysql_num_rows($Spending);
        while($row_Spending = mysql_fetch_assoc($Spending))
        {
        $spendingname[$x] = $row_Spending['ExpenditureName'];
        $spendingpercent[$x] = $row_Spending['SpendingPercent'];
        $spendingid[$x]= $row_Spending['SpendingID'];
        }
        mysql_free_result($Spending);
        }
    
    //To access and print all elements.
    for($x=1;$x<count($spendingname);$x++)
    {
    echo "The value for query $x";
    echo $spendingname[$x]."  ".$spendingpercent[$x]."  ".$spendingid[$x]."<br><br><br>";
    }
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey guys, I have developed a small site that i would like to embed
Hey guys, I have some questions would like to ask: I wanna ask how
Hey guys. Working on Mac OSX 10.6, My problem is that I would like
Hey guys, I have a WPF TreeView that has three nodes, I would like
Hey guys I would like to save some time....is there a form generator that
Hey guys. I would like to set up the alias in my enviromental file
Hey guys! I'm new to C, so i would like help in one problem.
Hey guys, I would like to develop a light/laser show editor and simulator, and
Hey guys, so I would like you to help with an issue that I'm
How I'm suppose to implement a macro that would do something like this: //pseudocode

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.