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>

Recommended Answers

All 11 Replies

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 :)

Did this solve your question Chris?

<?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

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];

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?

@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!

=)

I cant believe I actually didnt click with your issue earlier, sorry!

ohh thank too much my friends, this one work

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

Please mark this thread as solved and give rep to who you think helped you.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.