So to my knowledge I have a pretty simple piece of php that has been breaking my back all day
$startDate = "2016-07-27";
$endDate = "2016-07-31";
//--------------------------------------------------------------------------
// 1) Connect to mysql database
//--------------------------------------------------------------------------
$con = mysql_connect($host,$user,$pass);
$dbs = mysql_select_db($databaseName, $con);
//--------------------------------------------------------------------------
// 2) Query database for data
//--------------------------------------------------------------------------
$result = mysql_query("SELECT * FROM publishersStatistics WHERE dataDate BETWEEN STR_TO_DATE('" . $startDate . "','%Y-%m-%d') AND STR_TO_DATE('" . $endDate . "','%Y-%m-%d') ORDER by dataDate DESC");
$array = mysql_fetch_row($result); //fetch result
//--------------------------------------------------------------------------
// 3) echo result as json
//--------------------------------------------------------------------------
echo json_encode($array);
The code is very simple and this is the entire document (other than database connection stuff) - It takes a start date and end date and finds all values in-between those two dates. However for some reason it's only returning the last date in the query (2016-07-31)'s information.
I have no idea why this is!
I have also tested using ASC instead of DESC, this returns the first result. (2016-07-28)'s information only! Does anyone have any idea why I seem to be able to only recall one row?
Thanks in advance!