I'm trying to reconcile a bunch of documents/images that were deleted on a client server
I'm outputting a list of files that a number of clients have uploaded to a website and where records for the files were created in a DB. Some files still exist, the other have been unfortunately deleted and we need to contact the clients to get the images/documents back
right now everything outputs one record at a time and is a pain to work with
what I'd like todo is alter the output such that i can group all the files and related information by the client information to reduce the redundant info and to finally be able to automate generating emails with all the info in them (this i can do)
heres what I'm working with (sensitive info has been *** out):
<?php
// Report all PHP errors
error_reporting(E_ALL);
function array_remove_empty($arr)
{
$narr = array();
while(list($key, $val) = each($arr))
{
if (is_array($val))
{
$val = array_remove_empty($val);
if (count($val)!=0)
{
$narr[$key] = $val;
}
}
else
{
if (trim($val) != "")
{
$narr[$key] = $val;
}
}
}
unset($arr);
return $narr;
}
function status($image,$ext,$file,$location,$brokerEmail,$brokerName,$broker,$brokerPhone,$cnt)
{
if ($cnt % 2 == 0)
{
return "<div style=\"background-color:#FFFFCC\"><br><img src=\"".$ext.".png\" alt=\"".$ext."\" title=\"".$ext."\" /> <img src=\"".$image."\" alt=\"\" /> <b>".$file."</b><br/>[$location] [<a href=\"mailto:".$brokerEmail."\">$brokerName @ $broker</a>] [$brokerPhone]<br><br></div>\n\n";
}
else
{
return "<div style=\"background-color:#DBEEF3\"><br><img src=\"".$ext.".png\" alt=\"".$ext."\" title=\"".$ext."\" /> <img src=\"".$image."\" alt=\"\" /> <b>".$file."</b><br/>[$location] [<a href=\"mailto:".$brokerEmail."\">$brokerName @ $broker</a>] [$brokerPhone]<br><br></div>\n\n";
}
}
$dbusername='***';
$dbpassword='***';
$servername='***';
$link = mssql_connect ($servername,$dbusername,$dbpassword);
$query = 'select fileName, OfficeParkName, Broker, BrokerFirstName, BrokerLastName, BrokerEmail, BrokerPhone from cms_cpl c inner join CMS_cpl_files cf on c.itemId=cf.itemid order by Broker asc';
$result = mssql_query($query,$link);
$n = 0;
$y = 0;
$cnt = 0;
$doc = '***';
$img = '***';
$typ = array();
?>
<a href="?show_all=1" alt="Show All">Show All</a> | <a href="?show_all=0" alt="Show Missing">Show Missing</a>
<hr>
<?php
while ($row = mssql_fetch_array($result))
{
$file = $row['fileName'];
$location = $row['OfficeParkName'];
$broker = $row['Broker'];
$brokerName = $row['BrokerFirstName']." ".$row['BrokerLastName'];
$brokerPhone = $row['BrokerPhone'];
$brokerEmail = $row['BrokerEmail'];
if(strrpos($file,'.'))
{
$dot = strrpos($file,'.') +1;
$ext = substr($file,$dot);
}
if (file_exists($img.$file) && isset($_GET['show_all']) && $_GET['show_all']=='1')
{
echo status("check.png",$ext,$file,$location,$brokerEmail,$brokerName,$broker,$brokerPhone,$cnt);
$y++;
$cnt++;
}
elseif (file_exists($doc.$file) && isset($_GET['show_all']) && $_GET['show_all']=='1')
{
echo status("check.png",$ext,$file,$location,$brokerEmail,$brokerName,$broker,$brokerPhone,$cnt);
$y++;
$cnt++;
}
elseif (!file_exists($img.$file))
{
echo status("error.png",$ext,$file,$location,$brokerEmail,$brokerName,$broker,$brokerPhone,$cnt);
$n++;
$cnt++;
}
elseif (!file_exists($doc.$file))
{
echo status("error.png",$ext,$file,$location,$brokerEmail,$brokerName,$broker,$brokerPhone,$cnt);
$n++;
$cnt++;
}
else
{
echo "Error<br/>";
}
if (!in_array(strtolower($ext),$typ))
{
$typ[] = strtolower($ext);
}
}
$t = $n + $y;
echo "<hr>";
echo "<img src=\"error.png\" alt=\"\" />: $n <br/>";
echo "<img src=\"check.png\" alt=\"\" />: $y <br/>";
echo "<img src=\"document.png\" alt=\"\" />: $t <br/>";
?>
so basically I'm looking for output to be like this:
-----------------------------one client------------------------------------
location - email link - phone <--- group output based on this
<typ><ERROR><filename> <-- loop out this info
location - email link - phone <--- group output based on this
<typ><CHECK><filename> <-- loop out this info
you can see that I also provide the ability to show both ALL files and just missing... the missing should be grouped separately... so each client could inevitably have two containers of output
i can handle all the fancy output formatting... i really just need to know HOW to do this kind of grouping
hopefully this makes sense to someone... im happy provide any information that i havent included and thank everyone who helps