Jump to content

Showing the dollar sign?


eduard

Recommended Posts

what do you mean showing the dollar sign? If you are storing currency, then you would probably just want to store the actual monetary value, i.e. 4.99 and then just add the currency prefix when you output the value to the page. Decimal data type is probably want you want. Integers are just whole numbers (i.e. 1, 2, 3).

Link to comment
Share on other sites

what do you mean showing the dollar sign? If you are storing currency, then you would probably just want to store the actual monetary value, i.e. 4.99 and then just add the currency prefix when you output the value to the page. Decimal data type is probably want you want. Integers are just whole numbers (i.e. 1, 2, 3).
Maybe he should change it into VARCHAR? That way both the dollar sign and the price are stored.
Link to comment
Share on other sites

what do you mean showing the dollar sign? If you are storing currency, then you would probably just want to store the actual monetary value, i.e. 4.99 and then just add the currency prefix when you output the value to the page. Decimal data type is probably want you want. Integers are just whole numbers (i.e. 1, 2, 3).
No, I just want to show the dollar sign in my html table (as a result of SELECT)!
Link to comment
Share on other sites

Maybe he should change it into VARCHAR? That way both the dollar sign and the price are stored.
I know what he is implying, I'm just suggesting it's not necessarily the best approach. If he's saving currency, then he should just be saving it as what currency is, a decimal number. (to 2 places). Mixing strings/special characters into the mix isn't practical when...
No, I just want to show the dollar sign in my html table (as a result of SELECT)!
you can just use string concatenation. You're SELECT will return all the fields and values in your table. you can append/prepend anything you want to it after the fact. i.e.
$price = 4.99;echo 'the price of the product is $' . $price;

Link to comment
Share on other sites

I know what he is implying, I'm just suggesting it's not necessarily the best approach. If he's saving currency, then he should just be saving it as what currency is, a decimal number. (to 2 places). Mixing strings/special characters into the mix isn't practical when...you can just use string concatenation. You're SELECT will return all the fields and values in your table. you can append/prepend anything you want to it after the fact. i.e.
$price = 4.99;echo 'the price of the product is $' . $price;

Exactly, that´s what I need! But I will use this website in more countries (and other currency!). How do I do that?And how do I do that in this SELECT.php?<html><body><?php$con = mysql_connect("localhost","root","root");if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("Company", $con);$result = mysql_query("SELECT * FROM products");echo "<table border='1'><tr><th>description</th><th>price</th><th>quantity<th></tr>";while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['description'] . "</td>"; echo "<td>" . $row['price'] . "</td>"; echo "<td>" . $row['quantity'] . "</td>"; echo "</tr>"; }echo "</table>";mysql_close($con);?></body></html>
Link to comment
Share on other sites

why don't you try it first. You've already been given an example.
I always try first, but there is no $price in this file?
Link to comment
Share on other sites

:)good grief....haven't we told you a bunch of times that examples/tutorials are merely meant for illustrative purposes. In real life, the situation is always different, but the proof of concept is what is important to retain. I can't believe you won't even try it. You have something in that code that is outputting a price. Is it really that hard for you to take it to the next step to modify what you have to put a '$' in front of it?

Link to comment
Share on other sites

:)good grief....haven't we told you a bunch of times that examples/tutorials are merely meant for illustrative purposes. In real life, the situation is always different, but the proof of concept is what is important to retain. I can't believe you won't even try it. You have something in that code that is outputting a price. Is it really that hard for you to take it to the next step to modify what you have to put a '$' in front of it?
No, but maybe it´s a ( or a" or a ] or a ;, etc.) You´ll never know (do you remember one of my first posts in this forum? Is it a dollar sign (because also that was (very) difficult to read)!
Link to comment
Share on other sites

I really don't know what you're trying to say.If you want a dollar sign, just print a dollar sign, and the value next to it.

echo '$';echo $row['price'];

Link to comment
Share on other sites

No, but maybe it´s a ( or a" or a ] or a ;, etc.) You´ll never know (do you remember one of my first posts in this forum? Is it a dollar sign (because also that was (very) difficult to read)!
You should really read the php manual cover to virtual cover.That way, you'll have a firm understanding of the syntax php uses.
Link to comment
Share on other sites

No, but maybe it´s a ( or a" or a ] or a ;, etc.) You´ll never know (do you remember one of my first posts in this forum? Is it a dollar sign (because also that was (very) difficult to read)!
I just showed you an example how to do it and there were absolutely none of those other characters involved. What don't you understand about it? You asked how to put the $ there, now you don't know if what I showed you was a dollar sign? If you can't read your own monitor screen, that what do you expect us to do about it? What have you done about it? If nothing, then you have no one to blame but yourself.fix your darn screen man, this is ridiculous.
Link to comment
Share on other sites

I really don't know what you're trying to say.If you want a dollar sign, just print a dollar sign, and the value next to it.
echo '$';echo $row['price'];

Ok, thanks!
Link to comment
Share on other sites

I just showed you an example how to do it and there were absolutely none of those other characters involved. What don't you understand about it? You asked how to put the $ there, now you don't know if what I showed you was a dollar sign? If you can't read your own monitor screen, that what do you expect us to do about it? What have you done about it? If nothing, then you have no one to blame but yourself.fix your darn screen man, this is ridiculous.
I hope my new computer will solve this problem!
Link to comment
Share on other sites

you shouldn't need a new computer just to see it better, you just actually need to do something with the one you have.options already mentioned:1) decrease the resolution of your monitor/screen2) use the zoom feature of your web browser3) get a code editor with syntax highlighting4) use different fontsbut again, anything simple with eduardchile is difficult by default :)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...