[eluser]ywftdg[/eluser]
I have found the information above very helpful for future developments and looping through arrays. Although, I have found rebuilding some older code, which I was close to getting working, to be too much of a overhaul. In the end, I have to move on due to deadlines, since I have been on this for the entire work week, with no working example yet. I did the nastiness of just tweaking the old php code to work in my view file. Sometimes, time wins in the end. I thought I post my original code I was trying to port to CI, just to show how something like this, is very difficult to port over. I am sure most of this is because I am not the best coder really. but this was the first time I found CI to be more of a time waster, harder to use, than coding in my old fashion non framework methods. Either way, thanks for all the help guys, I will keep trekking on with CI, this in no way will stop my interest or progression with CI.
Old code snippet
Code:
<?
// Get designer's base payout percentage
$query = "select dpercentages from designer where ddesignerid = $DesignerId";
$result = mysql_query($query);
if($row = mysql_fetch_row($result)) {
$BasePercentage = $row[0];
} else {
$BasePercentage = 0;
}
$query = "select psku, pname, pcost, pprice, pskulist from products where pskulist <> ''";
$result = mysql_query($query);
$GrandTotal = 0;
$GrandQty = 0;
$GrandSales = 0;
while($row = mysql_fetch_row($result)) {
$BundleTotal = 0;
$BundleProfit = 0;
// Get the non-discounted total for this bundle
$query2 = "select sum(pprice) from products where psku in ($row[4])";
$result2 = mysql_query($query2);
if($row2 = mysql_fetch_row($result2)) { $BaseBundlePrice = $row2[0]; } else { $BaseBundlePrice = 0; }
//echo $BaseBundlePrice."<br>";
$Discount = $row[3] / $BaseBundlePrice;
$query2 = "select psku, pname, pcost, pprice from products where psku in ($row[4]) and pdesignerid = $DesignerId";
$result2 = mysql_query($query2);
if(mysql_num_rows($result2) > 0) {
while($row2 = mysql_fetch_row($result2)) {
$query3 = "select sum(oquantity) from orderdetail inner join receipt on oOrderNum = rOrderNum where osku = '$row[0]' and " . $query_date;
$result3 = mysql_query($query3);
if($row3 = mysql_fetch_row($result3)) {
$BundleProfit += ($row2[3] * $Discount) * ($BasePercentage / 100);
$BundleTotal += ((($row2[3] * $Discount) * $row3[0]) * ($BasePercentage / 100));
}
}
$GrandQty += $row3[0];
$GrandTotal += $BundleTotal;
$GrandSales += $row[3] * $row3[0];
?>
<tr>
<td nowrap bgcolor="#B9B9B9"><font class="blackText"><? echo $row[0]; ?></font></td>
<td nowrap bgcolor="#B9B9B9"><font class="blackText"><? echo $row[1]; ?></font></td>
<td nowrap bgcolor="#B9B9B9"><font class="blackText">$<? echo number_format($row[2] / 100, 2); ?></font></td>
<td nowrap bgcolor="#B9B9B9"><font class="blackText">$<? echo number_format($row[3] / 100, 2); ?></font></td>
<td nowrap bgcolor="#B9B9B9"><font class="blackText">$<? echo number_format(($BundleProfit / 100), 2); ?></font></td>
<td nowrap bgcolor="#DDDDDD"><font class="blackText"><? echo $row3[0]; ?></font></td>
<td nowrap bgcolor="#B9B9B9"><font class="blackText">$<? echo number_format((($row[3] * $row3[0]) / 100), 2); ?></font></td>
<td nowrap bgcolor="#B9B9B9"><font class="blackText">$<? echo number_format($BundleTotal / 100, 2); ?></font></td>
</tr>
<?
}
}
?>
<TR>
<TD colspan=5 nowrap> </TD>
<TD nowrap><font class="lightText"><B>#Sold</B></font></TD>
<TD nowrap><font class="lightText"><B>Sales Total</B></font></TD>
<TD nowrap><font class="lightText"><B>Sales Profit</B></font></TD>
</tr>
<tr>
<td colspan=5 nowrap bgcolor="#B9B9B9"> </td>
<td nowrap bgcolor="#DDDDDD"><font class="blackText"><b><? echo $GrandQty; ?></b></font></td>
<td nowrap bgcolor="#B9B9B9"><font class="blackText"><b>$<? echo number_format(($GrandSales / 100), 2); ?></b></font></td>
<td nowrap bgcolor="#B9B9B9"><font class="blackText"><b>$<? echo number_format($GrandTotal / 100, 2); ?></b></font></td>
</tr>
</table>
</p>