Greetings,

I am having trouble with the following code.  I am trying to make a table in
plain text to send via email.  I get the data frm a MYSQL table and then put
it into an array.  I find the max strlen and subtract each individual
customer name strlen from that and add that many spaces.  Such that if Max
was 10 and a particular one was 3 it would add 7 spaces.  It works fine most
of the time but my customer fwd me an email where it wasnt.

Can someone suggest a better way?  I wonder if I have the cart in front of
my horse but Im not sure of any better way.

I appreciate any help.

Thanks,

Leonard.
www.phpna.com


//Get data from tables
if ($result[1])
{
        while ($row = mysql_fetch_array($result[1]))
        {
                $cust = $row["customer"];
                $cust = get_acct_names($cust, customer);
                $data[$z][cust]=$cust;
                $data[$z][strlen]=strlen($cust);
                //Get longest customer string
                if ($data[$z][strlen] > $data[1][$z-1][strlen])
                {
                        $maxstrlen=strlen($cust);
                }

                $data[$z][date]=the_big_date($row["date"], "/");
                $data[$z][amount]="$".number_format($row["amount"], 2);
                $z++;

        }
        mysql_free_result($result[1]);
}


$msg[$i]="Revenue for $mon $yr\n";
$i++;

for ($y=0; $y < $z; $y++)
{
        //Find String Length Difference
        $deltastr = $maxstrlen - $data[$y][strlen];
        $cust_str .= repeater(" ", $deltastr);

        $cust = $data[$y][cust].repeater(" ", $deltastr);

$msg[$i]=$data[$y][date]."\t\t".$cust."\t\t".$data[$y][amount]."\n";

        $i++;
}

Leonard.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to