Reputation: 441
I am a novice in PHP. I have the following snippet from my PHP Code
$select = "SELECT budgetname,SUM(budgetamount) AS budget,sqlitebudgetid FROM budget WHERE budgettype = 'INCOME' AND budgetaccount = '$budgetAccount' AND budgetuser = '$userID' AND budgetdate BETWEEN '$fromDate' AND '$toDate' GROUP BY BudgetName ASC";
$result = mysqli_query($con, $select);
while($row = mysqli_fetch_array($result)) {
$rowIncomeBudgetLabels[] = $row["budgetname"];
$rowIncomeBudgetAmounts = array($row["budget"],$row["budget"], row["sqlitebudgetid"]);
}
I have tried to put the last part $rowIncomeBudgetAmounts into the following array but the result only display the first line.
I tried as below but id not working :
$data = array($rowIncomeBudgetAmounts);
Want to put to an array as below : so that each line is displayed as a separate sub array. Please help.
$data = array( array( 255, 100, 100 ),
array( 100, 255, 100 ),
array( 100, 100, 255 ),
array( 255, 255, 100 ),
);
EDIT >>
I am getting the following results ; instead of several lines - I am only getting the first line. On the graph all descriptions are showing but without all corresponding figures.
PERFECT : This is the result I wanted : Thanks @Ultrazz008
Upvotes: 1
Views: 55
Reputation: 1688
You should change the line from:
$rowIncomeBudgetAmounts = array($row["budget"],$row["budget"], row["sqlitebudgetid"]);
to:
$rowIncomeBudgetAmounts[] = array($row["budget"],$row["budget"], $row["sqlitebudgetid"]);
And you will get array of array data, appended []
at the end of $rowIncomeBudgetAmounts
, and the $
missing from the row["sqlitebudgetid"]
And after that use:
$data = $rowIncomeBudgetAmounts;
to get the:
array( array(), array(), array() )
- of your data.
Here's the way you wish it, and the code i posted in answer how it works:
Upvotes: 1