Arrays and While Mysql Functions

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Pezmc
Forum Commoner
Posts: 53
Joined: Mon Nov 06, 2006 2:15 pm

Arrays and While Mysql Functions

Post 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";
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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?
Post Reply