Code: Select all
andCode: Select all
tags where approriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Hi
Im i total newbie to php, and need help showing subtotals in my result set. any help would be greatly appreciated.
I have a mssql stored procedure which has a table with
the following data:-Code: Select all
Name Date Amount
Jack 11/11/2005 500.00
Jack 12/12/2005 100.00
Jill 11/11/2005 200.00
Jill 11/11/2005 300.00Code: Select all
Name Amount 11/11/2005 12/11/2005
Jack 500.00 500.00
Jack 100.00 100.00
Jill 200.00 200.00
Jill 300.00 300.00Code: Select all
Name Amount 11/11/2005 12/11/2005
Jack 500.00 500.00
Jack 100.00 100.00
Jack Total 600.00 500.00 100.00
Jill 200.00 200.00
Jill 300.00 300.00
Jill Total 500.00 500.00Code: Select all
<html>
<body>
<?php
// Connect directly to the MS SQL server via DB Library
$con = mssql_connect ("********", "******", "********");
if($con)
{
mssql_select_db ("[********]", $con);
$sql= "exec sales_crosstab " ;
$sql.= " '10/2005', ";
$sql.= " '12/2005' ";
// Execute our query
$rs= mssql_query ($sql, $con);
if($rs)
{
$colCount = mssql_num_fields($rs);
echo "<table>\n";
echo " <tr>\n";
for($x = 0; $x < $colCount; $x++)
{
echo "<td><font size=4>" . mssql_field_name($rs, $x) . "</td>\n";
}
echo "<tr><td></td></tr>";
echo "<tr><td></td></tr>";
$rowcount = mssql_num_rows($rs);
}
$col = " ";
while($row = mssql_fetch_row($rs))
{
$rowcount = mssql_num_rows($rs);
echo " <tr>\n";
for($x = 0; $x < $colCount; $x++)
{
echo " <td>" . $row[$x] . "</td>\n";
$col = $row[0];
}
echo " </tr>\n";
}
echo "</table>\n";
echo "<br>";
echo "Total: " . $totalval;
mssql_close ($con);
}
;
//foreach($GLOBALS as $n => $v)
//{
// echo $n . " = " . $v . "<br>";
//}
?>
</body>
</html>Code: Select all
andCode: Select all
tags where approriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]