Hi guys, feeling especially newb today.
Here's my problem:
I'm using TCPDF to produce a PDF file that contains 3 columns, first name, last name, and an integer associated with each person.
My tables in mysql, however, are not ideally coordinated for this combo.
the code:
//assume $db connection and $pdf creation
$pdf->Multicell(30,12,'Last',0,'L',1,0,'','',true); //labelling columns here.
$pdf->Multicell(30,12,'First',0,'L',1,0,'','',true);
$pdf->Multicell(30,12,'Number of Shares',0,'R',1,1,'','',true);
$totalIDs = $db->query("SELECT First_Name,Last_Name,ShareholderID FROM ShareholderNames");
$idArray = $totalIDs->fetchAll();
unset($idArray[0]);unset($idArray[167]); //the unsets are fine.
$numberIDs = count($idArray);
$transactions = $db->query("SELECT Source_Shareholder,Destination_Shareholder,Number_Of_Shares FROM TransactionHistory ORDER BY TransactionID");
$transactionArray = $transactions->fetchAll();
$numberofTransactions = count($transactionArray);
$entryCounter = 0;
while($entryCounter < $numberofTransactions)//initially gets all of the shareholders
{
$source = $transactionArray[$entryCounter][0];$dest = $transactionArray[$entryCounter][1];$shares = $transactionArray[$entryCounter][2];
if($source != 0 && ($source != 99999))
{
$summaryArray[$source]['shares'] -= $shares;
}
if($dest != 0 && ($dest != 99999))
{
$summaryArray[$dest]['shares'] += $shares;
}
$entryCounter++; //this all works fine.
}
//okay so summary Array works
foreach($summaryArray as $characterID => $shareArray)$smallerArray)
{
//HERE is the crap that's driving me crazy!!!
//so $characterID gives me the ID numbers, but I need to access the next array below it
//I tried to do ($summaryArray as $characterID => $shareArray as $shares)
//but it didn't work.
//The array is formatted as $summaryArray[ID number][number of shares]
//I also have $idArray = [key][last name][first name][ID number].
//So i need to take the ID number from share array and use it to grab the names
//and then take the Number of shares and associate it with the ID number
//to produce three columns, last name, first name, number of shares.
$pdf->Multicell(30,12,$last,0,'L',1,0,'','',true);
$pdf->Multicell(30,12,$first,0,'L',1,0,'','',true);
$pdf->Multicell(30,12,$shares,0,'R',1,1,'','',true);
}
$pdf->Output('CurrentShareholders', 'F');
?>
Any help at the proper way to format this to get my desired result would be GREATLY appreciated. Thanks in advance for your time and knowledge.
-slight