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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Can you post that part of the code which prints out that part of the table so I can have a look at it.
ASKER
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>
<td align="right" style="white-space: nowrap">0,34</td>
ASKER
<?php
session_start();
include("secure.php");
?>
<html>
<head>
<!-- InstanceBeginEditable name="doctitle" -->
<title>cool_default.gif</t itle>
<!-- 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('../Connectio ns/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_Sumofca lls, $RedGum2) or die(mysql_error());
$row_Sumofcalls = mysql_fetch_assoc($Sumofca lls);
$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_i d, 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_Records et1, $RedGum2) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Records et1);
$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_r 1_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_r 2_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>Cal ls Received</strong></div></t d>
</tr>
<?php do { ?>
<tr>
<td><div align="center"><td height="18"><?php echo $row_Sumofcalls['SumOfcall s']; ?></div></td>
</tr>
<?php } while ($row_Sumofcalls = mysql_fetch_assoc($Sumofca lls)); ?>
</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_i d']; ?> </td>
<td height="5"><?php echo $row_Recordset1['dial_posi tion']; ?> </td>
<td height="5"><?php echo $row_Recordset1['spot_time ']; ?> </td>
<td height="5"><?php echo $row_Recordset1['calls']; ?> </td>
<td height="5"><?php echo $row_Recordset1['spot_date ']; ?> </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($Records et1)); ?>
</table>
<br>
<a href="default.php">Home</a >
<a href="../logoff.php">Logof f</a> </div>
<!-- InstanceEndEditable --></td>
<td rowspan="2"><img name="cool_default_r2_c3" src="images/cool_default_r 2_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_r 3_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($Sumofca lls);
mysql_free_result($Records et1);
?>
</body>
<!-- InstanceBegin template="/Templates/cool_ default.dw t" codeOutsideHTMLIsLocked="f alse" -->
</html>
<!-- InstanceEnd -->
session_start();
include("secure.php");
?>
<html>
<head>
<!-- InstanceBeginEditable name="doctitle" -->
<title>cool_default.gif</t
<!-- 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('../Connectio
?>
<?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_
$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_Sumofca
$row_Sumofcalls = mysql_fetch_assoc($Sumofca
$totalRows_Sumofcalls = mysql_num_rows($Sumofcalls
?>
<?php
$colname_date_of_spot = "1";
if (isset($HTTP_SESSION_VARS[
$colname_date_of_spot = $HTTP_SESSION_VARS['ref'];
}
mysql_select_db($database_
$query_Recordset1 = "SELECT tbl_spots.client_id, tbl_spots.spot_id, tbl_spots.station_id, tbl_station.dial_position,
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_Records
$row_Recordset1 = mysql_fetch_assoc($Records
$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_r
<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_r
<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>Cal
</tr>
<?php do { ?>
<tr>
<td><div align="center"><td height="18"><?php echo $row_Sumofcalls['SumOfcall
</tr>
<?php } while ($row_Sumofcalls = mysql_fetch_assoc($Sumofca
</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<
<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
</tr>
<td height="3">
<?php do { ?>
<tr>
<td height="5"><?php echo $row_Recordset1['station_i
<td height="5"><?php echo $row_Recordset1['dial_posi
<td height="5"><?php echo $row_Recordset1['spot_time
<td height="5"><?php echo $row_Recordset1['calls']; ?> </td>
<td height="5"><?php echo $row_Recordset1['spot_date
<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
<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
<input type ="hidden" name="spot_time_id" value="<?php echo $row_Recordset1['spot_time
<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($Records
</table>
<br>
<a href="default.php">Home</a
<a href="../logoff.php">Logof
<!-- InstanceEndEditable --></td>
<td rowspan="2"><img name="cool_default_r2_c3" src="images/cool_default_r
<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_r
<td><img src="images/spacer.gif" width="1" height="36" border="0" alt=""></td>
</tr>
</table>
<?php
mysql_free_result($Sumofca
mysql_free_result($Records
?>
</body>
<!-- InstanceBegin template="/Templates/cool_
</html>
<!-- InstanceEnd -->
ASKER
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.
The SumOfCalls has a label and textbox, notice how the textbox is on the right below the label.
ASKER
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/
https://www.experts-exchange.com/Web/Web_Languages/HTML/
ASKER
You just answered my Question this is a PHP file, but treat it as HTML
Thanks
Thanks
ASKER