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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.