I've created an array, but am struggling to get the end result I'm looking for - could anyone point me in the right direction?
Current result: http://www.equinefocus.co.uk/random/4l56fdfm/20091230.php
Array
$filters_array = array
(
"Filter001"=>array
(
"<a href="http://www.equinefocus.co.uk" target="blank">Filter 001: Where rating = 1</a>", // filter name and link
"SELECT * FROM timeform WHERE tfr='1'", // count rows - number of qualifiers
"SELECT * FROM timeform WHERE tfr='1' and WHERE pos='1'", // count rows - number of winners
"SELECT tfr, SUM(profit) FROM timeform GROUP BY tfr WHERE tfr='1'" // sum of profit column for qualifiers
),
"Filter002"=>array
(
"<a href="http://www.equinefocus.co.uk" target="blank">Filter 002: Where rating = 2</a>",
"SELECT * FROM timeform WHERE tfr='2'",
"SELECT * FROM timeform WHERE tfr='2' and WHERE pos='1'",
"SELECT tfr, SUM(profit) FROM timeform GROUP BY tfr WHERE tfr='2'"
),
"Filter003"=>array
(
"<a href="http://www.equinefocus.co.uk" target="blank">Filter 001: Where rating = 3</a>",
"SELECT * FROM timeform WHERE tfr='3'",
"SELECT * FROM timeform WHERE tfr='3' and WHERE pos='1'",
"SELECT tfr, SUM(profit) FROM timeform GROUP BY tfr WHERE tfr='3'"
)
); // after final grouping
End Code
<?php
include($_SERVER['DOCUMENT_ROOT'].'/random/4l56fdfm/includes/*****.php'); //connection information
include($_SERVER['DOCUMENT_ROOT'].'/random/4l56fdfm/includes/associative.php'); //array
foreach ($filters_array[0] as $sql)
{
$result = mysql_query($sql);
echo 'Filter name: ' . ($result) . ' xxx';
}
foreach ($filters_array[1] as $sql)
{
$result = mysql_query($sql);
echo 'Qualifiers: ' . mysql_num_rows($result) . ' rows';
}
foreach ($filters_array[2] as $sql)
{
$result = mysql_query($sql);
echo 'Winners: ' . mysql_num_rows($result) . ' rows';
}
foreach ($filters_array[3] as $sql)
{
$result = mysql_query($sql);
echo 'Profit ' . sum($result) . ' rows';
}
?>