Hope someone can help me on this.
I have this code.
$calendar->highlighted_dates = Array('2016-12-03', '2016-12-14', '2016-12-25' );
With it, i can have the dates highlighted in a calendar.
I'm Trying to get the same thing with a query using this code
$sql = mysql_query("SELECT * FROM event Order by Date");
while($row = mysql_fetch_array($sql)){
$Date.= "'".$row["Date"]."'".", ";
}
$arrayb=array("$Date");
$calendar->highlighted_dates = $arrayb;
If i echo $Date i get
'2016-12-03', '2016-12-14', '2016-12-25',
But if i Print_r ($arrayb) i get
Array([0]=>'2016-12-03', '2016-12-14', '2016-12-25',)
And nothing on Calendar. I guess the problem is the [0]=>, but i don't know how to remove it.
Thanks.
Final Code as suggested by Mark Baker:
$link= mysqli_connect("$host", "$username", "$password","$db_name")or die("cannot connect");
$dateArray = array();
$sql = mysqli_query($link, "SELECT * FROM event Order by Date");
while($row = mysqli_fetch_array($sql)){ $dateArray[] = $row["Date"]; }
$calendar->highlighted_dates = $dateArray;
$dateArray = array(); while($row = mysql_fetch_array($sql)){ $dateArray[] = $row["Date"]; }