2

This is my code in tmpl/defult.php of my Joomla 2.5 module:

$result = count($payed);
for($i=0;$i<$result;$i++)
{
   $pay=F.$payed[$i];
   echo "<td>".JText::_("$pay")."</td>";
   echo "<td>".number_format($item->$pay)."</td>";
   $paytotal=$pay+$paytotal;  // For last result
   echo "</tr>";
}

$payed is an Array. I get it from user and exploding by this Code :

$p = $params->get('pay_fields');
$payed = explode ("\n", $p);

in language file of this module I used general names for module parameters, like these :

F1="pay1"
F2="Pay2"
F5="Pay3"
F6="Pay4"

and my table in Database has column name like this:

F1  |  F2  |  F3  |  F4  |  F5  |  F6  |  F....
---------------------------------------------------
12  | 1247 | 1056 | 2368 | 2256 | 12510| ...

I want to make a table from all user entered database fileds. For example when user types in module parameters

1
2
5
6

script must be read F1,F2,F5 and F6 from Database and make table . I know script do this , but not exactly true ! it just shows last result ! and set 0 for other parameters! what's wrong ?

Know Module shows this result in frontend :

--------------------------------
F1     |          0
--------------------------------
F2     |          0
--------------------------------
F5     |          0
--------------------------------
Pay4   |       12,510
Jack Bonneman
  • 1,821
  • 18
  • 24
Metalife
  • 41
  • 4
  • This doesn't explain your problem, but you should use `'F' . ` not `F .` - you want the string `'F'`, not the value of the constant `F`. For backwards compatibility, PHP guesses what you mean, but it's bad practice to rely on it. – IMSoP Aug 19 '12 at 20:17
  • I tried this but the answer did not change. – Metalife Aug 19 '12 at 22:53
  • could you give me a clue. what is F? – Josua Marcel C Aug 21 '12 at 16:29
  • F is a Prifix of My Dtabase Table Column.F1 name of Fisrt Column , F2 Second Column , F3 Third Column ,... – Metalife Aug 22 '12 at 05:20

1 Answers1

0

The problem was resolved with a funny way!

I just Change seperator From " \n " to " ; " and enterd number with the new symbol !

But I still do not understand what the problem was!

However, now it is working fine :D.

Mike Mackintosh
  • 13,917
  • 6
  • 60
  • 87
Metalife
  • 41
  • 4