I am having troubles pulling a row from sql query and storing it into an array. Here is my code.
$sql = "SELECT water, importdate
FROM customer_table
WHERE customer_number = '" . $custNum . "';";
$result_of_login_check = $this->db_connection->query($sql);
echo $sql . "<br>";
$result = mysqli_query($this->db_connection,$sql);
// set array
$array = array();
// look through query
while($row = mysqli_fetch_assoc($result)){
// add each row returned into an array
$array[] = $row;
}
print_r($array);
This is what the output looks like when I print the array,
Array (
[0] => Array (
[water] => 23
[importdate] => 2014-03-29
)
[1] => Array (
[water] => 33
[importdate] => 2015-02-22 )
)
While it is storing, I am stuck at trying to figure out how to copy each row into the array so it looks like this,
Array (
[water] => 23
[importdate] => 2014-03-29
)
Array (
[water] => 33
[importdate] => 2015-02-22
)
Which is each row stored in $row.
What I am going for is that I need to pull a list of bill amount and dates from the same customer from my database and then display each month by date. Showing the current months bill.
Thanks for your help!