jamus
1
Hi,
I am retrieving prices from a database. What I would like to do is replace instances where the value is 0.00 with “N/A”.
Something like:
# if no price replace with N/A
if ($row['price'] = '0.00')
{
echo str_replace("0.00","N/A",$row['price']);
}
else {
echo $row['price']);
};#end
Could someone help with this?
jdiben
2
You don’t need to use str_replace. Just echo “N/A” instead.
#if no price replace with N/A
if ($row['price'] = '0.00')
{
echo "N/A"
}
else {
echo $row['price']);
};#end
I dont get the problem. Tell me more please I’ll try to help.
SpikeZ
4
Add an equals sign if you are comparing
if(this == that) {
}
Also you dont need str_replace in this example
if ($row['price'] == '0.00') {
echo 'N/A';
} else {
echo $row['price'];
}
jamus
5
Thanks people! Only
Parse error: syntax error, unexpected '}', expecting ',' or ';' in /home/15330/map_asset/data.xml.php on line 110
110 { echo “N/A” }
#if no price replace with N/A
if ($row['price'] = '0.00') {
echo "N/A"
} else {
echo $row['price'];
}
@Jeremy - the single equals sign there would be taken as an assignment - setting $row[‘price’] to ‘0.00’.