This topic is locked

How can I display a £ in this code?

2/9/2008 3:34:38 AM
PHPRunner General questions
S
swanside author

In this code below, What can I change so i displays a £ before the value?

global $conn;

$sql = "select Unit_Price from material where job_no='".postvalue("editid1")."'";

$rs = db_query($sql,$conn);

$data = db_fetch_array($rs);

if(!$data)

return;

echo "<table>";

while(1)

{

echo "<tr>";

foreach($data as $v)

{

echo "<td>";

echo htmlspecialchars($v);

echo "</td>";

}

echo "</tr>";

if(!($data = db_fetch_array($rs)))

break;

}

echo "</table>";
J
Jane 2/11/2008

Hi,
use format_currency function in your code:

...

echo htmlspecialchars(format_currency($v));

...


Also don't forget to setup correct regional settings on the Miscellaneous tab.

S
swanside author 4/24/2008

Sorry about this, but, How do I display a % in the code??
I have tried echo htmlspecialchars(%($v)); but I get errors??
Cheers
Paul.

J
Jane 4/24/2008

Hi,
try to concat your value and %:

echo "%".htmlspecialchars($v);

S
swanside author 4/24/2008

Hi,

try to concat your value and %:


Thanks Jane.
That works, but it puts the % before the value i.e. %10.00 and not 10.00%
Cheers

Paul.

S
swanside author 4/24/2008

It works now.
I did this
echo htmlspecialchars($v)."%";
Thanks Jane
Paul.