Forums

PHP Echo Question

Manofstyle 27 Jun, 2012
I've searched everywhere and even php and mysql's websites as well as stack overflow. I've never learned how to do this and I guess I'll just ask the question.

I have a form that captures information. Say fields: grandtotal, expensetotal, and spendable. I'd like to use the php echo to populate the information. Currently I've been using the text field and I think having the echo would be cleaner display.

In addition, if the information in the fields are just numbers say 18923 is there an easy way with the php echo to have it display $18,923 ?

So I don't know what information is need.
Table name is: u6tdn_budgetpage7
Field name is: grandtotal
Manofstyle 28 Jun, 2012
Figured it out!🙂


This will display the field:
<?php echo $data['grandtotal']; ?>

This will display the field as currency format:
$<?php echo number_format($data['grandtotal'], 2, '.', ',');?>
GreyHead 29 Jun, 2012
Hi Manofstyle,

Perfect, well done!

Bob
Manofstyle 30 Jun, 2012
I'm having one small issue... I'm trying to input an {expense} in an email template and this won't populate anything.

<?php
$form->data['expense'] = echo number_format($data['grandtotal'], 2, '.', ',');
?>


I've tried
<?php
$form->data['expense'] = number_format($data['grandtotal'], 2, '.', ',');
?>


and this populates 0.00. Any ideas?
GreyHead 01 Jul, 2012
HI manofstyle,

Where does $data['grandtotal'] get its value from? It looks as though this may be zero.

Bob
Manofstyle 01 Jul, 2012
A form table called budget7. I use the same function earlier and it works. I just had an idea.
Manofstyle 02 Jul, 2012
Added "form->" and works perfectly! ha

Here's the code:
<?php
$form->data['expense'] = number_format($form->data['expensetotal'], 2, '.', ',');
?>
This topic is locked and no more replies can be posted.