vBR
Mon 10th Mar '03, 9:35am
This is a portion of a some php script I am writing to fetch the company's tour dates from a database.
All is working except for a section where I need to find the max and min values of a column in an array.
I would like to be able to use php to find these values from the existing array rather that querying the database again.
// ################################ start query database ################################
// create sql statement
$sql = "SELECT tour.startdate, tour.enddate, production.production, production.html, venue.venue, venue.addressc FROM (tour LEFT JOIN production USING (productionid)) LEFT JOIN venue ON tour.venueid = venue.venueid WHERE startdate $operator UNIX_TIMESTAMP(CURRENT_DATE) ORDER BY tour.startdate $order";
//execute sql query
$sql_result = mysql_query($sql, $connection) or die ("Could not execute query.");
// ################################ start navigation ################################
$getvar=MYSQL_FETCH_ARRAY($sql_result);
$dates=$getvar["startdate"];
$yearmin = min($dates);
$yearmax = max($dates);
for ($i=&yearmin;$i=&yearmax;$i++) {
echo "<a href=\"#$i\"> ";
}
All is working except for a section where I need to find the max and min values of a column in an array.
I would like to be able to use php to find these values from the existing array rather that querying the database again.
// ################################ start query database ################################
// create sql statement
$sql = "SELECT tour.startdate, tour.enddate, production.production, production.html, venue.venue, venue.addressc FROM (tour LEFT JOIN production USING (productionid)) LEFT JOIN venue ON tour.venueid = venue.venueid WHERE startdate $operator UNIX_TIMESTAMP(CURRENT_DATE) ORDER BY tour.startdate $order";
//execute sql query
$sql_result = mysql_query($sql, $connection) or die ("Could not execute query.");
// ################################ start navigation ################################
$getvar=MYSQL_FETCH_ARRAY($sql_result);
$dates=$getvar["startdate"];
$yearmin = min($dates);
$yearmax = max($dates);
for ($i=&yearmin;$i=&yearmax;$i++) {
echo "<a href=\"#$i\"> ";
}