Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
I need help before I run a muck
Old 04-05-2005, 01:35 PM I need help before I run a muck
merlin's Avatar
Skilled Talker

Posts: 52
Trades: 0
Hello,

I have a simple problem but every solution I get or find doesn't work. I have attached my code for my search results page and I'm hoping some here is smarter or is just a better freaking programmer than I am.

I need in add the code for the following.

Since the dollars being entered from the main input page only have a decimal place (no coma (,)) I am hoping someone could enlighten me on how I could modify my existing code to reflect proper dollar amounts (i.e. - 1000.00 should be 1,000.00)

Please fell free to change my code in order to make it work better. Thank GOD for these forums......


PHP Code:
<?php 
ob_start
();
session_start();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Pre-Outsourced Search Results</title>
<?php
include ('..\includes\cssinclude_2.php');
include (
'..\includes\meta.php');
?>
<style type="text/css">
<!--
.style2 {font-size: 14px}
-->
</style>
</head>

<body>
<div id="content">
<?php
include ('..\includes\outline.php');
?>
<div align="center">
<input type=button value="Use this Back Button Only" onClick="history.go(-2)"><br>
</div>
<?php
$rowcolor 
1;
//This is the file used to connect to the database.
require('mysql_connect_outsourced.php');

//Code used to search the database. This works with the code from the search form to generate the output.
    
if ((isset($_SESSION['Entered_Month'])) && (!isset($_SESSION['Agent']))) {
    
$sql_query "select * from accounts where Entered_Month = '" $_SESSION['Entered_Month'] . "'"

} elseif ((isset(
$_SESSION['Entered_Month'])) && (isset($_SESSION['Agent']))) {
    
$sql_query "select * from accounts where Entered_Month = '" $_SESSION['Entered_Month'] . "' AND Agent = '" $_SESSION['Agent'] . "'"

} elseif (isset(
$_SESSION['Entered_Year'])) {
    
$sql_query "select * from accounts where Entered_Year = '" $_SESSION['Entered_Year'] . "'";

} elseif ((isset(
$_SESSION['Entered_Year'])) && (isset($_SESSION['Agent']))) {
    
$sql_query "select * from accounts where Entered_Year = '" $_SESSION['Entered_Year'] . "' AND Agent = '" $_SESSION['Agent'] . "'"

} elseif (isset(
$_SESSION['Agent'])) {
    
$sql_query "select * from accounts where Agent = '" $_SESSION['Agent'] . "'";
    
} elseif (isset(
$_SESSION['Customer_Name'])) {
    
$sql_query "select * from accounts where Customer_Name = '" $_SESSION['Customer_Name'] . "'";

} elseif (isset(
$_SESSION['Account_Number'])) {
    
$sql_query "select * from accounts where Account_Number = '" $_SESSION['Account_Number'] . "'";
    }
    else { 
    die(
"Please input a vaild parameter to search");
    }
    

//set a variable called query_run to the execution on the query
$query_run mysql_query($sql_query);
$count mysql_num_rows($query_run);
$totalArrears "0.00";
$BalanceOwing "0.00";
$SettlementPaid "0.00"


?>

<table class="colortable" align="center" width="98%" border="5">
    <tr>
        <td class="color" align="center"><b><font color="white">Receipt Date</td>
        <td class="color" align="center"><b><font color="white">Agent</td>
        <td class="color" align="center"><b><font color="white">Customer Name</td>
        <td class="color" align="center"><b><font color="white">Account Number</td>
        <td class="color" align="center"><b><font color="white">Product</td>
        <td class="color" align="center"><b><font color="white">Balance Owing</td>
        <td class="color" align="center"><b><font color="white">Arrears Paid</td>
        <td class="color" align="center"><b><font color="white">Settlement Paid </td>
        <td class="color" align="center"><b><font color="white">Date Paid </td>
    </tr>
<br>


<?php
//Prints the query results.
print "<h3>Search Results: " $count " Account(s) Found</h3>";
while (
$query_res mysql_fetch_array($query_run)) {

    if (
$rowcolor == 1) {
        
$colorset "class=\"color1\""
        } else {
        
$colorset "class=\"color2\"";
        }
        
$totalArrears = ($totalArrears+$query_res['Arrears_Paid']);
        
$BalanceOwing = ($BalanceOwing+$query_res['Balance_Owing']);
        
$SettlementPaid = ($SettlementPaid+$query_res['Amount_Settled']);
        
        print
        
        
"<tr><td align=\"center\" {$colorset}>" $query_res['Entered_Month'] . " " $query_res['Entered_Day'] . ", " $query_res['Entered_Year'] . "</td>
        <td align=\"center\" 
{$colorset}>" $query_res['Agent'] . "</td>
        <td align=\"center\" 
{$colorset}>" $query_res['Customer_Name'] . "</td>
        <td align=\"center\" 
{$colorset}>" $query_res['Account_Number'] . "</td>
        <td align=\"center\" 
{$colorset}>" $query_res['Product_Type'] . "</td>
        <td align=\"center\" 
{$colorset}>$" $query_res['Balance_Owing'] . "</td>
        <td align=\"center\" 
{$colorset}>$" $query_res['Arrears_Paid'] . "</td>
        <td align=\"center\" 
{$colorset}>$" $query_res['Amount_Settled'] . "</td>
        <td align=\"center\" 
{$colorset}>" $query_res['Date_Settled'] . "</td></tr>
        <td align=\"center\" 
{$colorset}>"
        
        }
        

if (
$rowcolor == 1) {
            
$rowcolor++;
        } else {
        
$rowcolor--;
        }
        
        print 
'</table>';
    


?>
<br>



</table>
<div align="center">



<table width="40%" border="1" cellspacing="4" style="color: #FFFFFF; font-weight: bold" bgcolor="#000080" bordercolordark="#FFFFFF" bordercolorlight="#FFFFFF">
  <tr>
    <td width="55%"><span class="style2">Total Balances Owing</span></td>
    <td width="45%"><span class="style2">$<?php Print "$BalanceOwing";?></span></td>
  </tr>
  <tr>
    <td><span class="style2">Total Arrears Paid</span></td>
    <td><span class="style2">$<?php Print "$totalArrears";?>
    </span></td>
  </tr>
  <tr>
    <td><span class="style2">Total Settlements Paid</span></td>
    <td><span class="style2">$<?php Print "$SettlementPaid";?>
    </span></td>
  </tr>
</table>
<?php
mysql_close
(); // Close the database connection.
?> 

</div>
</div>
</div>
</body>
</html>

Last edited by merlin; 04-05-2005 at 01:56 PM..
merlin is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-05-2005, 02:06 PM
leavethisplace's Avatar
Ultra Talker

Posts: 297
Trades: 0
Well my dude! The answer is suprisingly simple (i think, cause i've never need to use it im just looking at the manual!)

number_format(); can do this for you, simply place the number you need to convert to having the comma in (otherwise known as "English Notation", very mathematical) between the brackets, like this:

PHP Code:
<?php

$number 
1234.56;

// english notation (default)
$english_format_number number_format($number);
// 1,234
 
?>
Hope that helped ya! Please tell me if it did work.
leavethisplace is offline
Reply With Quote
View Public Profile
 
Old 04-05-2005, 02:12 PM
leavethisplace's Avatar
Ultra Talker

Posts: 297
Trades: 0
Ah crappy bags, forgot something. You need decimals right? We need to tell number_format this, i think. Check this out:

PHP Code:
<?php

$number 
1234.56;

$number_format_decimalsnumber_format($number2'.'',');
// 1,234.56

?>
I think this is what needs to be done, but number_format may also work without having to define those extra bits there. Read up on it further by reading the php manual!
leavethisplace is offline
Reply With Quote
View Public Profile
 
Old 04-05-2005, 02:16 PM
merlin's Avatar
Skilled Talker

Posts: 52
Trades: 0
ARGH!, Don't you hate it when the answer is right in front of your face but you're to stupid to see it? I am such a dumb ***

Thanks very much dude..........
merlin is offline
Reply With Quote
View Public Profile
 
Old 04-05-2005, 04:22 PM
merlin's Avatar
Skilled Talker

Posts: 52
Trades: 0
Worked like a charm, you're a freak'n genius
merlin is offline
Reply With Quote
View Public Profile
 
Old 04-05-2005, 10:02 PM
leavethisplace's Avatar
Ultra Talker

Posts: 297
Trades: 0
nice one dude, that might actually come in useful one day!
leavethisplace is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to I need help before I run a muck
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.55690 seconds with 12 queries