Jump to content

Formatting Dollar Amounts From Database


walston

Recommended Posts

Hello all. I wonder if someone can help me with formatting dollar amounts selected from a MySQL database? It's probably something very easy for most of you, but I'm not very good at MySQL functions or syntax. The pages I created that connects to the database were created using Dreamweavers functionality, just so you all know I'm a MySQL dummy! LOL!

 

Anyways, what I am trying to accomplish is I have an administration section for my shopping cart. When I bring up the pages that list my orders etc, any dollar amounts listed aren't displaying the way I want them to. For example, instead of displaying 1024.00, it displays 1024. The first thing I want to figure out how to do is get even dollar amounts to display the zeros after the decimal (and also if the amount just has a zzero at the end like 1024.50, I'd like to get it to diplay the zero instead of it displaying 1024.5). Then, I would also like to figure out how to get a comma to display if the amount is 4 or more digits before the decimal. So instead of diplaying 1024.00, it displays 1,024.00.

 

Here is one of the pages of my administration section:

 

<?php require_once('../../Connections/Cart.php'); ?>
<?php
$currentPage = $_SERVER["PHP_SELF"];

if (!session_id()) session_start();
if (!isset($_SESSION["isAdmin"])) {
header("Location: login.php");
}
?>
<?php 
if (!isset($_POST['OrderUserLast']) || $_POST['OrderUserLast'] === "") {
  $_POST['OrderUserLast'] = "0";
}
if (!isset($_POST['OrderUserEmail']) || $_POST['OrderUserEmail'] === "") {
  $_POST['OrderUserEmail'] = "0";
}
if (!isset($_POST['OrderReferenceID']) || $_POST['OrderReferenceID'] === "") {
  $_POST['OrderReferenceID'] = "0";
}
if (!isset($_POST['OrderUserID']) || $_POST['OrderUserID'] === "") {
  $_POST['OrderUserID'] = "0";
}
?>
<?php
$maxRows_rsorders = 25;
$pageNum_rsorders = 0;
if (isset($_GET['pageNum_rsorders'])) {
  $pageNum_rsorders = $_GET['pageNum_rsorders'];
}
$startRow_rsorders = $pageNum_rsorders * $maxRows_rsorders;

$OrderUserLastParam_rsorders = "0";
if (isset($_POST['OrderUserLast'])) {
  $OrderUserLastParam_rsorders = (get_magic_quotes_gpc()) ? $_POST['OrderUserLast'] : addslashes($_POST['OrderUserLast']);
}
$OrderUserEmailParam_rsorders = "0";
if (isset($_POST['OrderUserEmail'])) {
  $OrderUserEmailParam_rsorders = (get_magic_quotes_gpc()) ? $_POST['OrderUserEmail'] : addslashes($_POST['OrderUserEmail']);
}
$OrderReferenceIDParam_rsorders = "0";
if (isset($_POST['OrderReferenceID'])) {
  $OrderReferenceIDParam_rsorders = (get_magic_quotes_gpc()) ? $_POST['OrderReferenceID'] : addslashes($_POST['OrderReferenceID']);
}
$OrderUserIDParam_rsorders = "0";
if (isset($_POST['OrderUserID'])) {
  $OrderUserIDParam_rsorders = (get_magic_quotes_gpc()) ? $_POST['OrderUserID'] : addslashes($_POST['OrderUserID']);
}
mysql_select_db($database_Cart, $Cart);
$query_rsorders = sprintf("SELECT * FROM orders INNER JOIN users on orders.OrderUserID = users.UserID WHERE (OrderReferenceID = '%s' OR '0' = '%s')  AND (OrderUserID = '%s' OR '0' = '%s')  AND (LastName LIKE '%s%%' OR '0' = '%s')  AND (UserEmail LIKE '%%%s%%' OR '0' = '%s')", $OrderReferenceIDParam_rsorders,$OrderReferenceIDParam_rsorders,$OrderUserIDParam_rsorders,$OrderUserIDParam_rsorders,$OrderUserLastParam_rsorders,$OrderUserLastParam_rsorders,$OrderUserEmailParam_rsorders,$OrderUserEmailParam_rsorders);
$query_limit_rsorders = sprintf("%s LIMIT %d, %d", $query_rsorders, $startRow_rsorders, $maxRows_rsorders);
$rsorders = mysql_query($query_limit_rsorders, $Cart) or die(mysql_error());
$row_rsorders = mysql_fetch_assoc($rsorders);

if (isset($_GET['totalRows_rsorders'])) {
  $totalRows_rsorders = $_GET['totalRows_rsorders'];
} else {
  $all_rsorders = mysql_query($query_rsorders);
  $totalRows_rsorders = mysql_num_rows($all_rsorders);
}
$totalPages_rsorders = ceil($totalRows_rsorders/$maxRows_rsorders)-1;

$queryString_rsorders = "";
if (!empty($_SERVER['QUERY_STRING'])) {
  $params = explode("&", $_SERVER['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
    if (stristr($param, "pageNum_rsorders") == false && 
        stristr($param, "totalRows_rsorders") == false) {
      array_push($newParams, $param);
    }
  }
  if (count($newParams) != 0) {
    $queryString_rsorders = "&" . htmlentities(implode("&", $newParams));
  }
}
$queryString_rsorders = sprintf("&totalRows_rsorders=%d%s", $totalRows_rsorders, $queryString_rsorders);

$maxRows_rsorders = 25;
$pageNum_rsorders = 0;
if (isset($_GET['pageNum_rsorders'])) {
  $pageNum_rsorders = $_GET['pageNum_rsorders'];
}
$startRow_rsorders = $pageNum_rsorders * $maxRows_rsorders;

$OrderUserLastParam_rsorders = "0";
if (isset($_POST['OrderUserLast']) && $_POST['OrderUserLast'] != "") {
  $OrderUserLastParam_rsorders = (get_magic_quotes_gpc()) ? $_POST['OrderUserLast'] : addslashes($_POST['OrderUserLast']);
}
$OrderUserEmailParam_rsorders = "0";
if (isset($_POST['OrderUserEmail']) && $_POST['OrderUserEmail'] != "") {
  $OrderUserEmailParam_rsorders = (get_magic_quotes_gpc()) ? $_POST['OrderUserEmail'] : addslashes($_POST['OrderUserEmail']);
}
$OrderReferenceIDParam_rsorders = "0";
if (isset($_POST['OrderReferenceID']) && $_POST['OrderReferenceID'] != "") {
  $OrderReferenceIDParam_rsorders = (get_magic_quotes_gpc()) ? $_POST['OrderReferenceID'] : addslashes($_POST['OrderReferenceID']);
}
$OrderUserIDParam_rsorders = "0";
if (isset($_GET['OrderUserID']) && $_GET['OrderUserID'] != "") {
  $OrderUserIDParam_rsorders = (get_magic_quotes_gpc()) ? $_GET['OrderUserID'] : addslashes($_GET['OrderUserID']);
}
?>
<html><!-- InstanceBegin template="/Templates/admin_template.dwt" codeOutsideHTMLIsLocked="false" -->
<HEAD>
<!-- InstanceBeginEditable name="doctitle" -->
<TITLE>Walston Net Design | Cart Administration | Orders</TITLE>
<!-- InstanceEndEditable -->
<META NAME="MSSmartTagsPreventParsing" CONTENT="TRUE">
<META NAME="Author" CONTENT="Walston Net Design   http://walstonet.com">
<META NAME="keywords" CONTENT="web designer,web designers,web design,web designs,hosting,web hosting,web site hosting,website hosting,cheap hosting,multimedia,multimedia design,multimedia designer,multimedia designers,360 degree virtual tours,programming,web programming,custom web programming,business card cd's,cd business cards,flash web site's,flash website's,graphic design,web graphics,print graphics,full service web design,banner design,web developers,domain registration,domain name registration,domain renewals,domain name renewals,logos,logo design,custom logo design,logos for print,print logos,graphics for print,graphics for the web,web design company,web design companies,web development company,web development companies,vernal,vernal ut,vernal utah,web design company in vernal,web design companies in vernal,web development company in vernal,web development companies in vernal,web design company in vernal ut,web design companies in vernal ut,web development company in vernal ut,web development companies in vernal ut,web design company in vernal utah,web design companies in vernal utah,web development company in vernal utah,web development companies in vernal utah">
<META NAME="description" CONTENT="Walston Net Design provides affordable full service web development services">
<META HTTP-EQUIV="imagetoolbar" CONTENT="no">
<META NAME="rating" CONTENT="General">
<META NAME="MS.LOCALE" CONTENT="EN-US">
<!-- InstanceBeginEditable name="meta" -->
<META NAME="CATEGORY" CONTENT="cart administration orders">
<META NAME="robots" CONTENT="orders_results,follow">
<!-- InstanceEndEditable -->
<META http-equiv="Classification" CONTENT="web development">
<META NAME="URL" CONTENT="http://walstonet.com">
<META NAME="revisit-after" CONTENT="31 days">
<META NAME="VW96.objecttype" CONTENT="web designer,web designers,web design,web designs,hosting,web hosting,web site hosting,website hosting,cheap hosting,multimedia,multimedia design,multimedia designer,multimedia designers,360 degree virtual tours,programming,web programming,custom web programming,business card cd's,cd business cards,flash web site's,flash website's,graphic design,web graphics,print graphics,full service web design,banner design,web developers,domain registration,domain name registration,domain renewals,domain name renewals,logos,logo design,custom logo design,logos for print,print logos,graphics for print,graphics for the web,web design company,web design companies,web development company,web development companies,vernal,vernal ut,vernal utah,web design company in vernal,web design companies in vernal,web development company in vernal,web development companies in vernal,web design company in vernal ut,web design companies in vernal ut,web development company in vernal ut,web development companies in vernal ut,web design company in vernal utah,web design companies in vernal utah,web development company in vernal utah,web development companies in vernal utah">
<META NAME="DC.Title" CONTENT="web designer,web designers,web design,web designs,hosting,web hosting,web site hosting,website hosting,cheap hosting,multimedia,multimedia design,multimedia designer,multimedia designers,360 degree virtual tours,programming,web programming,custom web programming,business card cd's,cd business cards,flash web site's,flash website's,graphic design,web graphics,print graphics,full service web design,banner design,web developers,domain registration,domain name registration,domain renewals,domain name renewals,logos,logo design,custom logo design,logos for print,print logos,graphics for print,graphics for the web,web design company,web design companies,web development company,web development companies,vernal,vernal ut,vernal utah,web design company in vernal,web design companies in vernal,web development company in vernal,web development companies in vernal,web design company in vernal ut,web design companies in vernal ut,web development company in vernal ut,web development companies in vernal ut,web design company in vernal utah,web design companies in vernal utah,web development company in vernal utah,web development companies in vernal utah">
<META NAME="DC.Subject" CONTENT="web designer,web designers,web design,web designs,hosting,web hosting,web site hosting,website hosting,cheap hosting,multimedia,multimedia design,multimedia designer,multimedia designers,360 degree virtual tours,programming,web programming,custom web programming,business card cd's,cd business cards,flash web site's,flash website's,graphic design,web graphics,print graphics,full service web design,banner design,web developers,domain registration,domain name registration,domain renewals,domain name renewals,logos,logo design,custom logo design,logos for print,print logos,graphics for print,graphics for the web,web design company,web design companies,web development company,web development companies,vernal,vernal ut,vernal utah,web design company in vernal,web design companies in vernal,web development company in vernal,web development companies in vernal,web design company in vernal ut,web design companies in vernal ut,web development company in vernal ut,web development companies in vernal ut,web design company in vernal utah,web design companies in vernal utah,web development company in vernal utah,web development companies in vernal utah">
<META NAME="DC.Description" CONTENT="Walston Net Design provides affordable full service web development services">
<META NAME="DC.Coverage.PlaceName" CONTENT="Global">
<!--
web designer,web designers,web design,web designs,hosting,web hosting,web site hosting,website hosting,cheap hosting,multimedia,multimedia design,multimedia designer,multimedia designers,360 degree virtual tours,programming,web programming,custom web programming,business card cd's,cd business cards,flash web site's,flash website's,graphic design,web graphics,print graphics,full service web design,banner design,web developers,domain registration,domain name registration,domain renewals,domain name renewals,logos,logo design,custom logo design,logos for print,print logos,graphics for print,graphics for the web,web design company,web design companies,web development company,web development companies,vernal,vernal ut,vernal utah,web design company in vernal,web design companies in vernal,web development company in vernal,web development companies in vernal,web design company in vernal ut,web design companies in vernal ut,web development company in vernal ut,web development companies in vernal ut,web design company in vernal utah,web design companies in vernal utah,web development company in vernal utah,web development companies in vernal utah
-->
<LINK REL="SHORTCUT ICON" a href="/favicon.ico">
<link rel="stylesheet" href="../../css/styles.css">
<script type="text/javascript" language="JavaScript1.2" src="../../java/stm31.js"></script>
<script type="text/javascript" language="JavaScript1.2" src="../../java/mouseovers.js"></script>
<script type="text/javascript" language="JavaScript1.2" src="../../java/lowercase.js"></script>

<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
</HEAD>
<body>
<table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td valign="top"><table width="100%"  border="0" cellpadding="0" cellspacing="0" background="../../images/top_menu_bg.gif">
      <tr valign="top">
        <td width="41"><img src="../../images/top_search_icon.gif" width="41" height="40" alt="Search"></td>
          <td width="185" valign="top" background="../../images/top_search_bg.gif"><table width="185" height="100%"  border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td valign="top" width="185" height="1"><img src="../../images/top_search_spacer.gif" width="185" height="1" alt="Walston Net Design"></td>
              </tr>
            <tr>
              <td valign="middle"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
                <form name="search" method="post" action="../../search.php"><tr>
                  <td width="4"><img src="../../images/top_search_spacer3.gif" alt="Walston Net Design" width="1" height="38"></td>
                  <td width="96" valign="bottom"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td valign="bottom"><input name="keyword" type="text" class="yellowforminput" id="keyword" onFocus="if(this.value=='enter keyword(s)')value=''" onBlur="if(this.value=='')value='enter keyword(s)';" value="enter keyword(s)" size="15"></td>
                    </tr>
                    <tr>
                      <td height="4" valign="bottom"><img src="../../images/top_search_spacer4.gif" width="97" height="4"></td>
                    </tr>
                  </table></td>
                  <td width="85" valign="bottom"> 
                    <input name="submit" type=IMAGE id="submit" value="submit" src="../../images/yellow_search_button.gif" alt="Search"  width=48 height=18 border=0></td>
                </tr>
                </form>
              </table></td>
            </tr>
            <tr>
              <td valign="bottom" width="185" height="1"><img src="../../images/top_search_spacer2.gif" width="185" height="1" alt="Walston Net Design"></td>
              </tr>
          </table></td>
        <td width="168"><img src="../../images/logo_top.gif" width="168" height="40" alt="Walston Net Design"></td>
        <td width="17"><img src="../../images/top_right.gif" width="17" height="40" alt="Walston Net Design"></td>
        <td width="100%" valign="middle"><script type="text/javascript" language="JavaScript1.2" src="../../java/menu.js"></script></td>
      </tr>
    </table>
      <table width="100%"  border="0" cellpadding="0" cellspacing="0" background="../../images/view_cart_bg.gif">
        <tr valign="top">
          <td width="19"><img src="../../images/icons_left.gif" width="19" height="95" alt="Walston Net Design"></td>
          <td width="30"><table width="30"  border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td valign="top"><img src="../../images/home_icon_top.gif" alt="Walston Net Design" width="30" height="24"></td>
            </tr>
            <tr>
              <td valign="top"><a href="../../index.php"><img src="../../images/home_icon.gif" alt="Home" width="30" height="28" border="0" title="Home"></a></td>
            </tr>
            <tr>
              <td valign="top"><img src="../../images/home_icon_bottom.gif" width="30" height="43" alt="Walston Net Design"></td>
            </tr>
          </table>            </td>
          <td width="6"><img src="../../images/icons_divider1.gif" width="6" height="95" alt="Walston Net Design"></td>
          <td width="29"><table width="29"  border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td valign="top"><img src="../../images/contact_icon_top.gif" width="29" height="37" alt="Walston Net Design"></td>
            </tr>
            <tr>
              <td valign="top"><a href="../../contact.php"><img src="../../images/contact_icon.gif" alt="Contact Us" width="29" height="28" border="0" title="Contact Us"></a></td>
            </tr>
            <tr>
              <td valign="top"><img src="../../images/contact_icon_bottom.gif" alt="Walston Net Design" width="29" height="30"></td>
            </tr>
          </table></td>
          <td width="7"><img src="../../images/icons_divider2.gif" width="7" height="95"></td>
          <td width="29"><table width="29"  border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td valign="top"><img src="../../images/sitemap_icon_top.gif" width="29" height="46" alt="Walston Net Design"></td>
            </tr>
            <tr>
              <td valign="top"><a href="../../sitemap.php"><img src="../../images/sitemap_icon.gif" alt="Sitemap" width="29" height="29" border="0" title="Sitemap"></a></td>
            </tr>
            <tr>
              <td valign="top"><img src="../../images/sitemap_icon_bottom.gif" width="29" height="20" alt="Walston Net Design"></td>
            </tr>
          </table></td>
          <td width="37"><img src="../../images/icons_right1.gif" width="37" height="95" alt="Walston Net Design"></td>
          <td width="37"><img src="../../images/icons_right2.gif" width="37" height="95" alt="Walston Net Design"></td>
          <td width="37"><img src="../../images/icons_right3.gif" width="37" height="95" alt="Walston Net Design"></td>
          <td width="37"><img src="../../images/icons_right4.gif" width="37" height="95" alt="Walston Net Design"></td>
          <td width="37"><img src="../../images/logo1.gif" width="37" height="95" alt="Walston Net Design"></td>
          <td width="37"><img src="../../images/logo2.gif" width="37" height="95" alt="Walston Net Design"></td>
          <td width="37"><img src="../../images/logo3.gif" width="37" height="95" alt="Walston Net Design"></td>
          <td width="37"><img src="../../images/logo4.gif" width="37" height="95" alt="Walston Net Design"></td>
          <td width="37"><img src="../../images/logo_right1.gif" width="37" height="95" alt="Walston Net Design"></td>
          <td width="37"><img src="../../images/logo_right2.gif" width="37" height="95" alt="Walston Net Design"></td>
          <td width="31"><table width="31"  border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td valign="top"><img src="../../images/view_cart_top.gif" width="31" height="39" alt="Walston Net Design"></td>
            </tr>
            <tr>
              <td valign="top"><img src="../../images/blank_view_cart_icon.gif" alt="Walston Net Design" width="31" height="41" border="0"></td>
            </tr>
            <tr>
              <td valign="top"><img src="../../images/view_cart_bottom.gif" width="31" height="15" alt="Walston Net Design"></td>
            </tr>
          </table></td>
          <td width="100%"><table width="100%" height="95"  border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td width="142" height="36" valign="top"><img src="../../images/view_cart_text_top.gif" width="142" height="36" alt="Walston Net Design"></td>
            </tr>
            <tr>
              <td height="59" valign="top" background="../../images/view_cart_text_bottom.gif" class="small"></td>
            </tr>
          </table></td>
        </tr>
      </table>      
      <table width="100%"  border="0" cellspacing="0" cellpadding="0">
        <tr valign="top">
          <td width="585"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td valign="top"><img src="../../images/main_top1.gif" width="585" height="13" alt="Walston Net Design"></td>
            </tr>
            <tr>
              <td valign="top"><img src="../../images/main_top22.gif" width="585" height="13" alt="Walston Net Design"></td>
            </tr>
            <tr>
              <td valign="top"><img src="../../images/main_top32.gif" width="585" height="13" alt="Walston Net Design"></td>
            </tr>
            <tr>
              <td valign="top"><img src="../../images/main_top42.gif" width="585" height="13" alt="Walston Net Design"></td>
            </tr>
          </table></td>
          <td valign="top"><div align="right" class="small"><a href="index.php" title="Home"><font color="FFFFFF">Home</font></a> | <a href="orders_results.php" title="Show All Orders"><font color="FFFFFF">Show All Orders</font></a> | <a href="orders_search.php" title="Search Orders"><font color="FFFFFF">Search Orders</font></a>    <br>
            <a href="products_results.php" title="Show All Services"><font color="FFFFFF">Show All Services</font></a> | <a href="products_search.php" title="Search Services"><font color="FFFFFF">Search Services</font></a> | <a href="products_insert.php" title="Add New Service"><font color="FFFFFF">Add New Service</font></a>    <br>
            <a href="users_results.php" title="Show All Users"><font color="FFFFFF">Show All Users</font></a> | <a href="users_search.php" title="Search Users"><font color="FFFFFF">Search Users</font></a>    </div></td>
        </tr>
      </table>      
      <table width="100%"  border="0" cellpadding="0" cellspacing="0" background="../../images/main_top52_bg.gif">
        <tr valign="bottom">
          <td width="585"><img src="../../images/main_top52.gif" width="585" height="13"></td>
          <td></td>
        </tr>
      </table>
      <br>
      <table width="100%"  border="0" cellspacing="0" cellpadding="0">
        <tr valign="top">
          <td><!-- InstanceBeginEditable name="Main" -->
            <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="table">
              <tr>
                <td valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
    <tr>
      <td><span class="text">Here is a listing of logged orders. The administrator can click on the order number to view additional details or use the navigation above to request a new result set.</span></td>
    </tr>
    <tr>
      <td><table width="100%" border="0" align="left">
            <tr>
              <td align="center" class="smallbold"> <?php if ($pageNum_rsorders > 0) { // Show if not first page ?>
                <a href="<?php printf("%s?pageNum_rsorders=%d%s", $currentPage, 0, $queryString_rsorders); ?>" title="<< First"><< First</a>
                <?php } // Show if not first page ?> </td>
              <td align="center"> <?php if ($pageNum_rsorders > 0) { // Show if not first page ?>
                <a href="<?php printf("%s?pageNum_rsorders=%d%s", $currentPage, max(0, $pageNum_rsorders - 1), $queryString_rsorders); ?>" class="smallbold" title="< Previous">< Previous</a>
                <?php } // Show if not first page ?> </td>
              <td align="center"> <?php if ($pageNum_rsorders < $totalPages_rsorders) { // Show if not last page ?>
                <a href="<?php printf("%s?pageNum_rsorders=%d%s", $currentPage, min($totalPages_rsorders, $pageNum_rsorders + 1), $queryString_rsorders); ?>" class="smallbold" title="Next >">Next ></a>
                <?php } // Show if not last page ?> </td>
              <td align="center"> <?php if ($pageNum_rsorders < $totalPages_rsorders) { // Show if not last page ?>
                <a href="<?php printf("%s?pageNum_rsorders=%d%s", $currentPage, $totalPages_rsorders, $queryString_rsorders); ?>" class="smallbold" title="Last >>">Last >></a>
                <?php } // Show if not last page ?> </td>
            </tr>
          </table></td>
    </tr>
    <tr>
      <td>      <table width="100%" cellpadding="5" cellspacing="0">
        <tr>
          <td colspan="4" class="text">Orders <?php echo ($startRow_rsorders + 1) ?> - <?php echo min($startRow_rsorders + $maxRows_rsorders, $totalRows_rsorders) ?> of <?php echo $totalRows_rsorders ?> </td>
        </tr>
        <tr valign="top" class="tableheader">
          <td align="left">Customer </td>
          <td width="120" align="left">Order Number </td>
          <td width="154" align="left">Order Date</td>
          <td align="center"><div align="right">Order Total</div></td>
          </tr>
        <?php do { ?>
        <tr class="nonbold">
            <td valign="top" align="left"><?php echo $row_rsorders['FirstName']; ?> <?php echo $row_rsorders['LastName']; ?></td>
            <td valign="top" align="left"><a href="orders_details.php?OrderID=<?php echo $row_rsorders['OrderID']; ?>" title="<?php echo $row_rsorders['OrderReferenceID']; ?>"><?php echo $row_rsorders['OrderReferenceID']; ?></a></td>
            <td valign="top" align="left" nowrap><?php echo substr($row_rsorders['OrderDate'],0,strpos($row_rsorders['OrderDate']," ")); ?></td>
            <td valign="top" align="center"><div align="right">$<?php echo $row_rsorders['OrderTotal']; ?></div></td>
            </tr>
        <?php } while ($row_rsorders = mysql_fetch_assoc($rsorders)); ?>
<tr valign="bottom">
          <td colspan="3"> </td>
          <td align="right"> </td>
          </tr>
      </table></td>
    </tr>
    <tr>
      <td><p> </p>
        <p> </p>
        <p> </p>
        <p> </p>
        <p> </p>
        <p> </p></td>
    </tr>
  </table></td>
              </tr>
            </table>
          <!-- InstanceEndEditable -->
          </td>
        </tr>
      </table>      
      <table width="100%"  border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td height="33" valign="top" background="../../images/bottom_top_bg.gif"><img src="../../images/bottom_top2.gif" width="387" height="33" alt="Walston Net Design"></td>
        </tr>
        <tr>
          <td valign="top"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
            <tr valign="top">
              <td width="400" height="24" background="../../images/bottom1.gif"> </td>
              <td width="100%" rowspan="2" valign="bottom" background="../../images/bottom_bg.gif"><div align="center" class="bottommenu">
                <table width="100%"  border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td valign="bottom"><div align="center" class="bottommenu"><a href="../../index.php" title="Home"><font color="#2D5B92">Home</font></a> | <a href="../../contact.php" title="Contact Us"><font color="#2D5B92">Contact Us</font></a> | <a href="../../policy.php" title="Acceptable Use Policy, Terms & Conditions"><font color="#2D5B92">Acceptable Use Policy, Terms & Conditions</font></a></div></td>
                  </tr>
                  <tr>
                    <td valign="bottom"><div align="center"><img src="../../images/bottom_spacer.gif" alt="Walston Net Design" width="1" height="10"></div></td>
                  </tr>
                </table>
                </div></td>
            </tr>
            <tr valign="top">
              <td width="400" height="22" background="../../images/bottom3.gif"><img src="../../images/copyright.gif" width="400" height="22" alt="© 2005 Walston Net Design. All rights reserved."></td>
              </tr>
          </table></td>
        </tr>
      </table>      </td>
  </tr>
</table>
</body>
<!-- InstanceEnd --></html>
<?php
mysql_free_result($rsorders);
?>

 

I know that most real coders don't like the way Dreamweaver codes things, but since I don't know much I have to do it that way, so if someone is willing to help me with this, I'd like to keep the formatting the way Dreamweaver does it so that I can follow it when maintaining my pages.

 

If anyone could help me with formatting the dollar totals I would really appreciate it. I'm sure it's something simple and regular to most of you but I just can't figure out how to do it. I'm hoping if someone can show me how to do it with the page I've included, I can copy the method on my other admin pages that need it. If not, is there somewhere here that I can request to hire it out? There's probably only 5-7 pages total that need it.

 

Thanks so much for any help in advance, I appreciate it!!!

 

 

Link to comment
Share on other sites

the code is quite long to go through, but what you do is quite simple. Assuming the field is called `price` and is a number value (not varchar), then the following query gives you the formatted string.

[!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']SELECT[/span] FORMAT(price,2) AS formatted FROM .... [!--sql2--][/div][!--sql3--]

 

You can integrate the FORMAT part into your current queries.

Hope this helped.

Link to comment
Share on other sites

Thanks for replying ryanlwh.

 

Actually, I was able to fix the problem of it not displaying zeros after the decimal or even if the last number is a zero (such as 1024.50). All I had to do was change the row type to float(10,2) on all rows that are for dollar amounts and now it displays the zeros.

 

So now the only thing I have to do is get the comma added if the amount is four or more digits before the decimal.

 

I tried this that I found but it didn't work. I just added it as php before the html tag:

 

<?php

$number = 1234.56;

// english notation (default)
$english_format_number = number_format($number);
// 1,235

?>

 

Does anyone know an easy way to make sure a comma is used if the amount is four or more digits before the decimal?

 

Thanks again!!!

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.