Page 1 of 1

Arrays and While Mysql Functions

Posted: Thu Oct 18, 2007 2:19 pm
by Pezmc
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?

Code: Select all

//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";

Posted: Thu Oct 18, 2007 2:46 pm
by RobertGonzalez
Are you trying to append array members to another array or grow and array? I am not totally sure of what you want to do here?