[phorm] [Phorm:] ArrayToTable bug?

  • From: webbbs@xxxxxxxxx
  • To: support@xxxxxxxxx
  • Date: 6 Aug 2004 15:42:06 -0000

The following new message has been posted on Phorm Support Forum at 
<http://www.phorm.com/support/>. 

*************************************************************************** 

  MESSAGE:  (#4241) ArrayToTable bug? 
            <http://www.phorm.com/support/?rev=4241> 
  AUTHOR:   Charles 
  DATE:     August 6, 2004 at 11:42 a.m. EST 

In my config file I have: 
$OrderTable = ArrayToTable($vendor, $qty, $price, $total, $prod_num, $title, 
$code, ">> "); 

In my email.txt file I have: 
{{OrderTable}} 

I got phorm to email me this: 

vendor qty price total product/isbn title code 
------ --- ----- ----- ------------ ----- ---- 
asdfasdf assadf.. 3 34.00 102.00 one sdfsdf sdfsdfs .. 1234665 
asdfasdf 43 5.00 215.00 two sdfsdf sdfsdf 
asdfas 4 23.00 92.00 three sdfsdfs sdfsdfs.. sdf 
asdfsdfsdf sdfs.. 3 4.00 12.00 four sdlkff ---- 
sdfsdf 3 4.00 12.00 five sdfsdfsd 
------ --- ----- ----- ------- ----- 

$433.00 sub total 

$33.56 tax 

$5.00 est. shipping 

$20.00 processing fee 

$491.56 total 

Notice the "----" in the "code" column of product four... that should be part 
of the format line a few rows later. Additionally the "code" on product three 
is supposed to be on product five. I can add a "if (code == "") { $code = 
"--"; } to my "while" loop but this seems like a bug. Am I missing something? 

HERE IS THE CODE I USE TO BUILD THE ARRAY: 

<?php 
///////////////////////// 
// LETS BUILD AN ARRAY // 
///////////////////////// 

// BEFORE WHILE STATEMENT 
echo (" <input type=hidden name=\"vendor[0]\" value=\"vendor\">\n"); 
echo (" <input type=hidden name=\"qty[0]\" value=\"qty\">\n"); 
echo (" <input type=hidden name=\"price[0]\" value=\"price\">\n"); 
echo (" <input type=hidden name=\"total[0]\" value=\"total\">\n"); 
echo (" <input type=hidden name=\"prod_num[0]\" value=\"product/isbn\">\n"); 
echo (" <input type=hidden name=\"title[0]\" value=\"title\">\n"); 
echo (" <input type=hidden name=\"code[0]\" value=\"code\">\n"); 
echo (" <input type=hidden name=\"vendor[1]\" value=\"------\">\n"); 
echo (" <input type=hidden name=\"qty[1]\" value=\"---\">\n"); 
echo (" <input type=hidden name=\"price[1]\" value=\"-----\">\n"); 
echo (" <input type=hidden name=\"total[1]\" value=\"-----\">\n"); 
echo (" <input type=hidden name=\"prod_num[1]\" value=\"------------\">\n"); 
echo (" <input type=hidden name=\"title[1]\" value=\"-----\">\n"); 
echo (" <input type=hidden name=\"code[1]\" value=\"----\">\n"); 

$display = mysql_query("SELECT * FROM curriculum WHERE 1 AND 
ordernumber='$ordernumber' AND completed!='placeholder' ORDER BY uniqueid 
ASC"); 
$loopcount = 1; 

// INSIDE WHILE STATEMENT 
while ($row = mysql_fetch_array($display)) { 
$loopcount = ($loopcount +1); 

$vendor = $row["vendor"]; 
$qty = $row["qty"]; 
$price = $row["price"]; 
$price = number_format($price, 2, '.', ''); 
$total = ($price * $qty); 
$total = number_format($total, 2, '.', ''); 
$prod_num = $row["prod_num"]; 
$title = $row["title"]; 
$code = $row["code"]; 
if (strlen($vendor) >= 15) { $vendor = substr($row["vendor"],0,15).".. "; } 
if (strlen($title) >= 15) { $title = substr($row["title"],0,15).".. "; } 

echo (" <input type=hidden name=\"vendor[$loopcount]\" value=\"$vendor\">\n"); 
echo (" <input type=hidden name=\"qty[$loopcount]\" value=\"$qty\">\n"); 
echo (" <input type=hidden name=\"price[$loopcount]\" value=\"$price\">\n"); 
echo (" <input type=hidden name=\"total[$loopcount]\" value=\"$total\">\n"); 
echo (" <input type=hidden name=\"prod_num[$loopcount]\" 
value=\"$prod_num\">\n"); 
echo (" <input type=hidden name=\"title[$loopcount]\" value=\"$title\">\n"); 
echo (" <input type=hidden name=\"code[$loopcount]\" value=\"$code\">\n"); 
} // END WHILE 

// AFTER WHILE STATEMENT 
// GET TOTALS 
$subtot = mysql_query("SELECT SUM(total) FROM curriculum WHERE 
ordernumber='$ordernumber'"); 
list($subtotal) = mysql_fetch_row($subtot); 
$tax = ($subtotal * .0775); 
$tax = number_format($tax, 2, '.', ''); 
$ordertotal = ($subtotal + $tax + 5 + 20); 
$ordertotal = number_format($ordertotal, 2, '.', ''); 

$loopcount = ($loopcount + 1); 
echo (" <input type=hidden name=\"vendor[$loopcount]\" value=\"------\">\n"); 
echo (" <input type=hidden name=\"qty[$loopcount]\" value=\"---\">\n"); 
echo (" <input type=hidden name=\"price[$loopcount]\" value=\"-----\">\n"); 
echo (" <input type=hidden name=\"total[$loopcount]\" value=\"-----\">\n"); 
echo (" <input type=hidden name=\"prod_num[$loopcount]\" 
value=\"-------\">\n"); 
echo (" <input type=hidden name=\"title[$loopcount]\" value=\"-----\">\n"); 
echo (" <input type=hidden name=\"code[$loopcount]\" value=\"----\">\n"); 

$loopcount = ($loopcount + 1); 
echo (" <input type=hidden name=\"vendor[$loopcount]\" value=\" \">\n"); 
echo (" <input type=hidden name=\"qty[$loopcount]\" value=\" \">\n"); 
echo (" <input type=hidden name=\"price[$loopcount]\" value=\" \">\n"); 
echo (" <input type=hidden name=\"total[$loopcount]\" 
value=\"\$$subtotal\">\n"); 
echo (" <input type=hidden name=\"prod_num[$loopcount]\" value=\"sub 
total\">\n"); 
echo (" <input type=hidden name=\"title[$loopcount]\" value=\" \">\n"); 
echo (" <input type=hidden name=\"code[$loopcount]\" value=\" \">\n"); 

$loopcount = ($loopcount + 1); 
echo (" <input type=hidden name=\"vendor[$loopcount]\" value=\" \">\n"); 
echo (" <input type=hidden name=\"qty[$loopcount]\" value=\" \">\n"); 
echo (" <input type=hidden name=\"price[$loopcount]\" value=\" \">\n"); 
echo (" <input type=hidden name=\"total[$loopcount]\" value=\"\$$tax\">\n"); 
echo (" <input type=hidden name=\"prod_num[$loopcount]\" value=\"tax\">\n"); 
echo (" <input type=hidden name=\"title[$loopcount]\" value=\" \">\n"); 
echo (" <input type=hidden name=\"code[$loopcount]\" value=\" \">\n"); 

$loopcount = ($loopcount + 1); 
echo (" <input type=hidden name=\"vendor[$loopcount]\" value=\" \">\n"); 
echo (" <input type=hidden name=\"qty[$loopcount]\" value=\" \">\n"); 
echo (" <input type=hidden name=\"price[$loopcount]\" value=\" \">\n"); 
echo (" <input type=hidden name=\"total[$loopcount]\" value=\"\$5.00\">\n"); 
echo (" <input type=hidden name=\"prod_num[$loopcount]\" value=\"est. 
shipping\">\n"); 
echo (" <input type=hidden name=\"title[$loopcount]\" value=\" \">\n"); 
echo (" <input type=hidden name=\"code[$loopcount]\" value=\" \">\n"); 

$loopcount = ($loopcount + 1); 
echo (" <input type=hidden name=\"vendor[$loopcount]\" value=\" \">\n"); 
echo (" <input type=hidden name=\"qty[$loopcount]\" value=\" \">\n"); 
echo (" <input type=hidden name=\"price[$loopcount]\" value=\" \">\n"); 
echo (" <input type=hidden name=\"total[$loopcount]\" value=\"\$20.00\">\n"); 
echo (" <input type=hidden name=\"prod_num[$loopcount]\" value=\"processing 
fee\">\n"); 
echo (" <input type=hidden name=\"title[$loopcount]\" value=\" \">\n"); 
echo (" <input type=hidden name=\"code[$loopcount]\" value=\" \">\n"); 

$loopcount = ($loopcount + 1); 
echo (" <input type=hidden name=\"vendor[$loopcount]\" value=\" \">\n"); 
echo (" <input type=hidden name=\"qty[$loopcount]\" value=\" \">\n"); 
echo (" <input type=hidden name=\"price[$loopcount]\" value=\" \">\n"); 
echo (" <input type=hidden name=\"total[$loopcount]\" 
value=\"\$$ordertotal\">\n"); 
echo (" <input type=hidden name=\"prod_num[$loopcount]\" value=\"total\">\n"); 
echo (" <input type=hidden name=\"title[$loopcount]\" value=\" \">\n"); 
echo (" <input type=hidden name=\"code[$loopcount]\" value=\" \">\n"); 

?> 

*************************************************************************** 

This is an automatically-generated notice.  If you'd like to be removed from 
the mailing list, please visit Phorm Support Forum at 
<http://www.phorm.com/support/>, or send your request to webbbs@xxxxxxxxxx  If 
you wish to respond to this message, please post your response directly to the 
board.  Thank you! 
-------------------------------------------------
You are receiving this message because you are subscribed to the Phorm mailing 
list. To send messages to the mailing list, simply send email to 
phorm@xxxxxxxxxxxxx from the address you have subscribed. You may unsubscribe 
from the list by sending email to phorm-request@xxxxxxxxxxxxx with 
'unsubscribe' in the SUBJECT field.

Other related posts:

  • » [phorm] [Phorm:] ArrayToTable bug?