0

hello everybody
i buil my dynamic site in dreamweaver cs6 but i'm not abble to formate the nember i want format number to decimal number like float in phpmyadmin this is how i do and it don't work please help thank.

<label for="shipping">Sub total</label><input name="subtotal2" type="text"id="subtotal2" value="<?php echo $row_total[ number_format, 'sub_total, 2, ',' ''']; ?>" readonly>
3
Contributors
11
Replies
31
Views
4 Years
Discussion Span
Last Post by chrisschristou
Featured Replies
  • Are you trying to acheive something like this: <?php echo number_format($row_total['sub_total'], 2, '.', ''); ?> ? From the looks of it you're trying to use the `number_format` function on an array reference? You should instead call the function on the array variable itself. Does that make sense? Read More

  • 1

    @mmcdonald How would this work: <?php echo number_format($row_total['sub_total'], 2, '.', '')]; ?> Where did the last `]` come from? It should be: `<?php echo number_format($row_total['sub_total'], 2, '.', ''); ?>` Would work, I guess! =) Read More

0

Ewww Dreamweaver :'(

If you're dealing with currency, which it looks like you are, then you should definately use money_format().

http://www.php.net/manual/en/function.money-format.php

However if you just want want to have a decimal place and not a comma change it to this:

$row_total[ number_format, 'sub_total, 2, '.' ''']; ?>"

Notice the change of the comma to a period :)

0
<?php echo $row_total[ number_format 'sub_total, 2, '.', ''']; ?>"

i use this code and i get this error

Parse error: syntax error, unexpected ''sub_total, 2, '' (T_CONSTANT_ENCAPSED_STRING), expecting ']' in /homepages/0/d461548742/htdocs/zunaphone.com/myspace/panier.php on line 278
0

I'm no expert on this function, but shouldn't it be:

echo number_format((int)$row_total, 2,'.','');

Since you are denoting an array $row_total[blah];

Edited by phorce

1

Are you trying to acheive something like this:

<?php echo number_format($row_total['sub_total'], 2, '.', ''); ?>

?

From the looks of it you're trying to use the number_format function on an array reference? You should instead call the function on the array variable itself. Does that make sense?

Edited by mmcdonald

1

@mmcdonald

How would this work:

<?php echo number_format($row_total['sub_total'], 2, '.', '')]; ?>

Where did the last ] come from?

It should be:

<?php echo number_format($row_total['sub_total'], 2, '.', ''); ?>

Would work, I guess!

=)

0

ohh thank too much my friends, this one work

<?php echo number_format($row_total['sub_total'], 2, '.', ''); ?>
0

Phorce you must have loaded a second after I posted as I edited that extra ']'! You solution stealer!! :D It was a clear typo

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.