I have design a webpage to and make all necessary code in admin section. How do I call this value to show on the customer page in the number format?
I am trying to show the amount in double eval. I mean $750,100.15.
When a customer logs in the value will be shown on their page. I used the following code it work.
<?php echo $_SESSION['hlmgt_user']['amount']; ?>
This prints out $750100.15, but I need it to print $750,100.15. I am using the above code to call the value on customer page.
How to fix the below code to get it working?
<?php echo $_SESSION['hlmgt_user']number_format($row['balance'], 2); ?>
try this maybe helpful
<?php
$number = "750100.15";
setlocale(LC_MONETARY, 'en_US');
echo money_format('%(#10n', $number) . "\n";
?>
OUTPUT
$ 750,100.15
I think you should look about the "number_format" or "money_format" function in PHP here:
https://php.net/number_format
https://php.net/money_format
Related
I am printing the customers email address in the header like so:
<?php echo $email=$this->__('Hello, %s', Mage::getSingleton('customer/session')->getCustomer()->getEmail()); ?>
However I want to truncate this to a certain number due to users with long email addresses.
I have tried to use the truncate helper which magento has but I am getting no joy, wondering if anyone can help.
<?php echo $email=$this->__('Hello, %s', Mage::getSingleton('customer/session')->getCustomer()->getEmail()->truncate('text', 12)); ?>
Thanks
Ok if that ok then you are doing in wrong way.For truncate using Magento you should try like this :
<?php echo Mage::helper('core/string')->truncate('abacdkdslsdfkjdfss#yahoo.com', 12); ?>
AS for you email concerned you can try like this : User proper email getter function .you can assign that to any variable instead of echo
<?php echo Mage::helper('core/string')->truncate(Mage::getSingleton('customer/session')->getCustomer()->getEmail(), 12); ?>
OUTPUT : abacdkdslsdf
First parameter will be your string and second will be length of that text.Hope this will help you
So I'm setting up a little page for myself to see my online transactions in dogecoin.
I have the RPC server/client connection established and working correctly.
The listtransactions method provides me with the transaction history as an array, which breaks down into its elements. I embed these in a table.
That all works correctly. what I WANT is to take the transaction ID and make it linkable to the dogecoin blockchain record.
Here is the code, and then I will note which lines have the issue:
for($i=count($json)-1; $i>=0; $i--){
echo '<tr>';
echo '<td>'.$json[$i]['address'].'</td>'."\n";
//echo '<td>'.$json[$i]['category'].'</td>'."\n";
echo '<td>'.$json[$i]['amount'].'</td>'."\n";
//echo '<td>'.$json[$i]['confirmations'].'</td>'."\n";
echo '<td>'."<a href='https://dogechain.info/tx/$json[$i]['txid']'>".$json[$i]
['txid'].'</a> </td>'."\n";
echo '</tr>';
}
echo '</table></center>';
?>
The line containing the hyperlink is where it screws up. You can see how it is displaying at http://www.suchco.in/
an example link it gives me is: https://dogechain.info/tx/Array%5B
what it should be is: https://dogechain.info/tx/ fab3b949cb3a71e79fa6b631d5d16aa7268b77dc3626e2fb2e711f1b43adc08d
how can I make this happen?
Put { } around your array variables in a string.
Try:
{$json[$i]['txid']}
Instead of:
$json[$i]['txid']
OR
Do string concatenation
echo '<td>'."<a href='https://dogechain.info/tx/".$json[$i]['txid']."'>"
I have this piece of code:
if(isset($_POST['btnSubmit']) && $_POST['btnSubmit'])
{
require_once($_SERVER['DOCUMENT_ROOT'] . 'database.php');
$derpCard = $card;
$derpAccessGroup = $_POST['tbAccessGroup'];
$derpComments = $_POST['tbComments'];
if(isset($_POST['cbActivated']))
$derpActive = $_POST['cbActivated'];
else
$derpActive = "DEACTIVATED";
$x = editCard($derpCard,$derpAccessGroup, $derpComments, $derpActive);
if($x)
{
$_SESSION['editcard'] = $derpCard;
$_SESSION['editgroup'] = $derpAccessGroup;
$_SESSION['editcomments'] = $derpComments;
$_SESSION['editstatus'] = $derpActive;
echo "<script>";
echo "alert(\"Done!\");";
echo "</script>";
}
echo "<script>location.reload(true);</script>";
}
Basically, editCard runs an SQL "UPDATE ... where..." to edit the content within the db. If this is sucessful, I want it to display an alert telling the user it's been updated, as well as refresh the page.
Both the alert and reload code do not run, and i've been trying any and all alternatives! If someone has any idea as to simply refresh the page (thats the minimum i need!) It would be greatly appreciated!
I have to apologize if this answer is too short but the question is too broad or is missing more info. I noticed that one of your lines is wrong.
require_once($_SERVER['DOCUMENT_ROOT'] . 'database.php');
should be:
require_once($_SERVER['DOCUMENT_ROOT'] . '/database.php');
There should be / in it since $_SERVER['DOCUMENT_ROOT'] returns something like this:
"C:/xampp/htdocs"
So if you are to concatenate that with "database.php", you'll be having
"C:/xampp/htdocsdatabase.php" instead of "C:/xampp/htdocs/database.php"
In any case, you should try using firebug or similar browser add-on to help you debug those javascript errors(if there are any).
I hope this helps.
Try to format the script echo like this:
echo "\n<script>\n<!--\n";
echo "alert(\"Done!\");";
echo "\n-->\n</script>\n";
and
echo "\n<script>\n<!--\nlocation.reload(true);\n-->\n</script>\n";
Note the new lines added.
You appear to be missing the type attribute for script.
If you want to specify javascript, you need to include the type.
echo "<script type=\"text/javascript\">";
echo "alert(\"Done!\")";
echo "</script>";
Same goes with the other line
echo "<script type=\"text/javascript\">location.reload(true);</script>";
If the above does not help in the slightest, the problem could be with your logic statements, or that your javascript may just not be outputting what you want.
There are tools to help you figure out these issues, such as the apache logs and firebug plugin
EDIT: Forgot missing semicolon
hi guys im trying to show and hide div according to mysql value but i couldnt do it can you help me what im doing wrong
here is my code thanks a lot for your ideas
var Value = <?php echo json_encode($valuek) ?>;
if (Value==1){
$('#show_hide').show();
}
else{
$('#show_hide').hide();
}
<?php
$valuek = $session->userinfo['vcc'];
?>
<div id="show_hide">
some code
</div>
<?php echo json_encode($valuek) ?>
will return a json string, instead try just using "echo"
<?php echo $valuek ?>
If all you are going for is a boolean value then there is simply no need for JSON.
Echo the value directly into the JavaScript. Remember to ensure you are passing a valid boolean value.
PHP code -
<?php
$showDiv = ($dbValue == 1? 'true' : 'false');
?>
JavaScript + PHP injection -
<script>
var value = '<?php echo $showDiv; ?>';
<script>
Don't forget to wrap the PHP injected value with quotes.
$valuek = $session->userinfo['vcc'];
I'm not sure if you have the code in this order in your php file, or just showed pieces of code in this order, but Should go BEFORE your js code. It has no value when js code is run.
To see what $valuek is, just echo it on top of the screen
<?php echo "<h1>$valuek</h1>" ?>.
Or just look at the source - at your js function, to see what is printed after 'var Value ='
That's the main thing really - to make sure that you getting what you expect from session.
And as been said, you don't need jason_encode, but you do need a semi-colon after echo command.
Also, I hope your jquery code is within $(document).ready function, not as is.
I have a php function which displays a rating bar with the arguments. I have a variable called itemID inside my php page which holds the unique item number. I need to send this value to my function and also echo command must stay. Is there a way to achieve this?
Here is the code, which does not work. When I try it on the server, it does not show the id of item, it prints the variable name as it is.
<?php echo rating_bar('$as',5) ?>
What I get at html file:
<div id="unit_long$as">
instead of the item id in place of $as.
Single Quotes do not support variable replace,
$as = "test";
echo '$as'; //$as in your end result
echo "$as"; // test in your end result
echo $as; // test in your end result
//For proper use
echo " ".$as." "; // test in your end result
Update for newer PHP versions you should now use Template Syntax
echo "{$as}"
If I get what you are saying, this is what you are asking.
<?php echo rating_bar($itemID,5); ?>
With the limited code you are providing, thats what looks like you are asking.