Link to home
Start Free TrialLog in
Avatar of sendtojp
sendtojp

asked on

PHP Table in Web page mySQL Round to cents

I have a PHP file which displays a Table (grid on the screen not a database Table).  One of the fields is Cost/Call  which I get  by dividing  two mySQL fields.  I am a VB programmer not a PHP/mySQL programmer, but I must figure this out.  I need to round the number to the nearest cents.  HELP!  
ASKER CERTIFIED SOLUTION
Avatar of hernst42
hernst42
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sendtojp
sendtojp

ASKER

I am having trouble with the table spacing and justifaction.  Is there any tips you have?
Can you post that part of the code which prints out that part of the table so I can have a look at it.
Ok, let me remove the  client info
To get numeric content formated in a td I use typical

<td align="right" style="white-space: nowrap">0,34</td>
<?php
  session_start();
  include("secure.php");
?>
<html>
<head>
<!-- InstanceBeginEditable name="doctitle" -->
<title>cool_default.gif</title>
<!-- InstanceEndEditable -->
<meta http-equiv="Content-Type" content="text/html;">
<!-- Fireworks MX Dreamweaver MX target.  Created Wed Sep 18 14:44:05 GMT-0700 (Pacific Daylight Time) 2002-->
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
</head>
<body bgcolor="#ffffff">

<?php
require_once('../Connections/RedGum2.php');
?>
<?php
//This will remove the dashes in the date formatting from the variable $spot_date passed in the URL
$date = "$spot_date";
//split day, month and year into an array
$date_array = explode("-", $date);
//$spot_date in the new format
$date = $date_array[0] . $date_array[1] . $date_array[2];
?>

<?php
mysql_select_db($database_RedGum2, $RedGum2);
$query_Sumofcalls = "SELECT Sum(tbl_spot_times.calls) AS SumOfcalls, tbl_spots.spot_date, tbl_spots.client_id
FROM tbl_spots INNER JOIN tbl_spot_times ON tbl_spots.spot_id = tbl_spot_times.spot_id
GROUP BY tbl_spots.spot_date, tbl_spots.client_id
HAVING ((tbl_spots.client_id = " . $HTTP_SESSION_VARS['ref'] . ") and (tbl_spots.spot_date = $date))";
$Sumofcalls = mysql_query($query_Sumofcalls, $RedGum2) or die(mysql_error());
$row_Sumofcalls = mysql_fetch_assoc($Sumofcalls);
$totalRows_Sumofcalls = mysql_num_rows($Sumofcalls);
?>

<?php
      $colname_date_of_spot = "1";
if (isset($HTTP_SESSION_VARS['ref'])) {
  $colname_date_of_spot = $HTTP_SESSION_VARS['ref'];
}
mysql_select_db($database_RedGum2, $RedGum2);
$query_Recordset1 = "SELECT tbl_spots.client_id, tbl_spots.spot_id, tbl_spots.station_id, tbl_station.dial_position, tbl_spot_times.spot_time, tbl_spot_times.spot_time_id, tbl_spot_times.calls, tbl_spots.spot_date
      FROM (tbl_spot_times INNER JOIN tbl_spots ON tbl_spot_times.spot_id = tbl_spots.spot_id)
      LEFT JOIN tbl_station ON tbl_spots.station_id = tbl_station.call_letters
      WHERE ((tbl_spots.client_id = $colname_date_of_spot) and (tbl_spots.spot_date = $date))";
$Recordset1 = mysql_query($query_Recordset1, $RedGum2) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>

<table border="0" cellpadding="0" cellspacing="0" width="770">
<!-- fwtable fwsrc="Untitled" fwbase="cool_default.gif" fwstyle="Dreamweaver" fwdocid = "742308039" fwnested="0" -->
  <tr>
   <td><img src="images/spacer.gif" width="80" height="1" border="0" alt=""></td>
   <td><img src="images/spacer.gif" width="602" height="1" border="0" alt=""></td>
   <td><img src="images/spacer.gif" width="88" height="1" border="0" alt=""></td>
   <td><img src="images/spacer.gif" width="1" height="1" border="0" alt=""></td>
  </tr>

  <tr>
   <td colspan="3"><img name="cool_default_r1_c1" src="images/cool_default_r1_c1.gif" width="770" height="94" border="0" alt=""></td>
   <td><img src="images/spacer.gif" width="1" height="94" border="0" alt=""></td>
  </tr>
  <tr>
   <td rowspan="2"><img name="cool_default_r2_c1" src="images/cool_default_r2_c1.gif" width="80" height="337" border="0" alt=""></td>
    <td><!-- InstanceBeginEditable name="body" -->
      <div align="center">
        <p><strong><font size="5">Add Calls</font></strong></p>
        <table height="20" border="1">
          <tr>
            <td><div align="center"><strong>Calls Received</strong></div></td>
          </tr>
          <?php do { ?>
          <tr>
            <td><div align="center"><td height="18"><?php echo $row_Sumofcalls['SumOfcalls']; ?></div></td>
          </tr>
          <?php } while ($row_Sumofcalls = mysql_fetch_assoc($Sumofcalls)); ?>
        </table>        
       
       
       
        <table height="20" border="1">
          <tr>
            <td width="151" height="38"><strong>Call Letters</strong></td>
            <td width="169" height="38"><strong>Dial Position</strong></td>
            <td width="152" height="38"><strong>Spot Time</strong></td>
            <td width="119" height="38"><strong>Calls</strong></td>
            <td width="153" height="38"><strong>Spot Date</strong></td>
                  <td width="41" height="38"><strong>Add Call</strong></td>
                  <td width="49" height="38"><strong>Delete Call</strong></td>
          </tr>
          <td height="3">
          <?php do { ?>
          <tr>
            <td height="5"><?php echo $row_Recordset1['station_id']; ?>&nbsp;</td>
            <td height="5"><?php echo $row_Recordset1['dial_position']; ?>&nbsp;</td>
            <td height="5"><?php echo $row_Recordset1['spot_time']; ?>&nbsp;</td>
            <td height="5"><?php echo $row_Recordset1['calls']; ?>&nbsp;</td>
            <td height="5"><?php echo $row_Recordset1['spot_date']; ?>&nbsp;</td>
                  <td height="5"><div align="center">
                <form action="dc_add_call.php" method="post">
                        <input type ="hidden" name="spot_time_id" value="<?php echo $row_Recordset1['spot_time_id']; ?>">
                        <input type ="hidden" name="client_id" value="<?php echo $client_id; ?>">
                        <input type="hidden" name="spot_date" value="<?php echo $spot_date; ?>">
                        <input type="submit" name="Submit" value="Add"></form>
                                                                                          
              </div></td>
                    <td height="5"><div align="center">
                <form action="dc_delete_call.php" method="post">
                        <input type ="hidden" name="spot_time_id" value="<?php echo $row_Recordset1['spot_time_id']; ?>">
                        <input type ="hidden" name="client_id" value="<?php echo $client_id; ?>">
                        <input type="hidden" name="spot_date" value="<?php echo $spot_date; ?>">
                        <input type="submit" name="Submit" value="Delete"></form>
                                                                                          
              </div>
                    </td>
          </tr>
          <td height="4">
          <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
        </table>
        <br>
            <a href="default.php">Home</a>
        <a href="../logoff.php">Logoff</a> </div>
      <!-- InstanceEndEditable --></td>
   <td rowspan="2"><img name="cool_default_r2_c3" src="images/cool_default_r2_c3.gif" width="88" height="337" border="0" alt=""></td>
   <td><img src="images/spacer.gif" width="1" height="301" border="0" alt=""></td>
  </tr>
  <tr>
   <td><img name="cool_default_r3_c2" src="images/cool_default_r3_c2.gif" width="602" height="36" border="0" alt=""></td>
   <td><img src="images/spacer.gif" width="1" height="36" border="0" alt=""></td>
  </tr>
</table>
<?php
mysql_free_result($Sumofcalls);

mysql_free_result($Recordset1);
?>
</body>
<!-- InstanceBegin template="/Templates/cool_default.dwt" codeOutsideHTMLIsLocked="false" -->
</html>
<!-- InstanceEnd -->
There is a SumOfCalls on top with a Table below.

The SumOfCalls has a label and textbox, notice how the textbox is on the right below the label.
This is NOT my code by the way.  I have to make this work to get the project.
Hm can't see the problem, but am no real expert in HTML. You may ask this in the HTML-topicArea.

https://www.experts-exchange.com/Web/Web_Languages/HTML/
You just answered my Question this is a PHP file, but treat it as HTML

Thanks