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 Answer