usman07 Posted May 16, 2012 Share Posted May 16, 2012 I am coding using php and I am adding a pound sign in my mysql table but it outputs as a question mark, how do I make it output the pound sign? thanks. Quote Link to comment https://forums.phpfreaks.com/topic/262605-how-to-output-a-pound-sign-from-php/ Share on other sites More sharing options...
noXstyle Posted May 16, 2012 Share Posted May 16, 2012 Save the pound sign as £ to database. For example if you are saving input to database you would replace the pound sign like: $input = str_replace('£', '£', $input); Quote Link to comment https://forums.phpfreaks.com/topic/262605-how-to-output-a-pound-sign-from-php/#findComment-1345891 Share on other sites More sharing options...
usman07 Posted May 16, 2012 Author Share Posted May 16, 2012 I don't understand? do I enter the pound sign like '£' in the database, then what do I have to do to let it output that? heres the php code for the price: echo 'price="' . $row['price'] . '" '; Quote Link to comment https://forums.phpfreaks.com/topic/262605-how-to-output-a-pound-sign-from-php/#findComment-1345892 Share on other sites More sharing options...
noXstyle Posted May 16, 2012 Share Posted May 16, 2012 No. You save the pound sign as £ to database which is html entity equivalent to £. When you output the data from database the £ will automatically be converted to £. Quote Link to comment https://forums.phpfreaks.com/topic/262605-how-to-output-a-pound-sign-from-php/#findComment-1345895 Share on other sites More sharing options...
usman07 Posted May 16, 2012 Author Share Posted May 16, 2012 Iv tried that but does not work? what should the field type be when adding that in the database? at the moment the field type is 'VARCHAR' Quote Link to comment https://forums.phpfreaks.com/topic/262605-how-to-output-a-pound-sign-from-php/#findComment-1345896 Share on other sites More sharing options...
noXstyle Posted May 16, 2012 Share Posted May 16, 2012 varchar is fine. Do a var_dump() on the price field and see what it outputs. One tip though: It is way more convenient to save a price (since you're dealing with prices) as a numeric value to database. And then when you get the data you would echo it like: echo 'price="' . $row['price'] . ' £" '; So my suggestion is you make the type of price field as FLOAT or DOUBLE and append the pound sign to the price while outputting the data. That way you can do calculations with the price if needed in the future without processing the fields with php. Quote Link to comment https://forums.phpfreaks.com/topic/262605-how-to-output-a-pound-sign-from-php/#findComment-1345898 Share on other sites More sharing options...
usman07 Posted May 16, 2012 Author Share Posted May 16, 2012 Im basically creating a google maps feature and in the window info i want a price showing, when I use that php code you said all my markets disappear. Check the link here and click the yellow marker: http://www.mumtazproperties.hostei.com/map.html Quote Link to comment https://forums.phpfreaks.com/topic/262605-how-to-output-a-pound-sign-from-php/#findComment-1345901 Share on other sites More sharing options...
usman07 Posted May 16, 2012 Author Share Posted May 16, 2012 Fixed it, did this so just need to put the number in the database and the pound sign is in the php code: echo 'price="£' . $row['price'] . '" '; Quote Link to comment https://forums.phpfreaks.com/topic/262605-how-to-output-a-pound-sign-from-php/#findComment-1345908 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.