Jump to content

Arrays and While Mysql Functions


Pezmc

Recommended Posts

How can I get this array to work? I am trying to add data to an array for every row of data? This is a sellection of queries that I need to parse into an array so a function can use the arra to draw a graph. I am new to arrays how can I get this to work? Please help?

		//Sql Query
		//Day Name
		$sql = "SELECT count(*) as cnt, DAYNAME(date) as dnr, TO_DAYS(date) as tdr FROM $dbsql WHERE date >= DATE_SUB( CURRENT_DATE, INTERVAL 6 day ) GROUP BY dnr,tdr ORDER BY tdr";
		$result = mysql_query($sql);
		while ($row = mysql_fetch_array($result)) {
			$comma = ","; 
			$xdata .= '"'.$row[dnr].'"'.$comma;
		}

		//Data
		$sql = "SELECT count(*) as cnt, DAYNAME(date) as dnr, TO_DAYS(date) as tdr FROM $dbsql
		WHERE date >= DATE_SUB( CURRENT_DATE, INTERVAL 6 day ) GROUP BY dnr,tdr ORDER BY tdr";
		$result = mysql_query($sql);
		while ($row = mysql_fetch_array($result)) {
			$comma = ","; 
			$ydata .= $row[cnt].$comma;
		}
		//Trim Extra Commas
			$ydata = substr($ydata, 0, strlen($ydata)-1);
			$xdata = substr($xdata, 0, strlen($xdata)-1);

	$y = array($ydata);
	$x = array($xdata);	 
	$title = "Unique Hits/Day";
	$labelx = "Day";
	$labely = "Unique Hits"; 

Link to comment
https://forums.phpfreaks.com/topic/73855-arrays-and-while-mysql-functions/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.