#connect to MYSQL $conn = mysql_connect ("localhost", "ok", "ok") or die ( "Error: Could not connect to MySQL" ); #select the specified database $rs = mysql_select_db( "ok", $conn) or die ( "Error: Could not connect to the database" ); #create the query@@//Do not attempt to get MORE data than you need@@//The pipeline between MySQL and PHP is like the proverbial eye of a needle@@//Minimize traffic through that choke-point.@@ $sql = "SELECT date_format(Date, '%d'), count(*) as activity_count FROM Calendar WHERE '2006-06-00' < Date < '2006-07-00'"; #excute the query $rs = mysql_query( $sql, $conn); #write the data while ( $row = mysql_fetch_array( $rs ) ) {@@ $Date = $row['Date'];@@ $count = $row['activity_count'];@@// $array = $row['Date'];@@ $activities[$Date] = $count; }/* lots of code later, you have $d in your loop to print out each rectangle */ if (isset($activities[$d])) $color = 'yellow'; else $color = 'white'; echo "<td bgcolor=\"$color\">$d</td>\n";