[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 398
  • Last Modified:

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!  
0
sendtojp
Asked:
sendtojp
  • 6
  • 4
1 Solution
 
hernst42Commented:
0
 
sendtojpAuthor Commented:
I am having trouble with the table spacing and justifaction.  Is there any tips you have?
0
 
hernst42Commented:
Can you post that part of the code which prints out that part of the table so I can have a look at it.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
sendtojpAuthor Commented:
Ok, let me remove the  client info
0
 
hernst42Commented:
To get numeric content formated in a td I use typical

<td align="right" style="white-space: nowrap">0,34</td>
0
 
sendtojpAuthor Commented:
<?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 -->
0
 
sendtojpAuthor Commented:
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.
0
 
sendtojpAuthor Commented:
This is NOT my code by the way.  I have to make this work to get the project.
0
 
hernst42Commented:
Hm can't see the problem, but am no real expert in HTML. You may ask this in the HTML-topicArea.

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

Thanks
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 6
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now