Don’t know how to do what Kevin Rubio suggested.
I did add the code Topcoder suggested on lines 2 and 3, but got the same results…
inside while loop
was the only thing that displayed.
Not sure if this will help, but here is the MySQL table structure used in the problematic code and working code (at bottom of this post):
id_internet_sales -- int(6)
payee -- varchar(75)
email -- varchar(75)
order_date -- varchar(50)
order_date_no_time -- varchar(15)
name -- varchar(75)
address -- varchar(75)
address2 -- varchar(50)
city -- varchar(50)
state -- varchar(2)
zip -- varchar(10)
country -- varchar(50)
cost -- decimal(6,2)
origination -- varchar(75)
comments -- tinyblob
date_stamp -- varchar(50)
This a copy of working code (except date order which I’m seeking help with on another post - date comparison and formatted output) that pulls the order_date_no_time, name, and cost from table - displayed in table format:
[php]
// database stuff ***********************************************
// assign database info to php variable
$db_hostname = “";
$db_username = "”;
$db_password = “";
$database = "”;
// connect to database
mysql_connect($db_hostname, $db_username, $db_password);
@mysql_select_db($database) or die(“Unable to select database”);
// ************************************************************************************
$startdate = $_POST[‘startdate’];
$month_s = $startdate[0];
$day_s = intval($startdate[1]);
$year_s = $startdate[2];
$enddate = $_POST[‘enddate’];
$month_e = $enddate[0];
$day_e = intval($enddate[1]);
$year_e = $enddate[2];
// functions are at top of code, but not included on forum to save space – they work
// converts number to text representation of month
$month_s = month_convert($month_s);
$month_e = month_convert($month_e);
$month = month_convert_long_name($startdate[0]); // use in report title
// recombine POST data
$space = " ";
$start_date_mix = $month_s . $space . $day_s . $space . $year_s;
$end_date_mix = $month_e . $space . $day_e . $space . $year_e;
echo " Range of dates: " . $start_date_mix . " - " . $end_date_mix . “
”;
// pull data from DB that’s between dates
$result = mysql_query(“SELECT * FROM internet_sales_dw WHERE order_date_no_time BETWEEN ‘$start_date_mix’ AND ‘$end_date_mix’ ORDER BY CAST(order_date_no_time AS SIGNED)”) or die(mysql_error());
$row = mysql_fetch_array($result);
$match = 0; // # matches
$total_sales = 0;
$count = 1; // # items
// set up table
echo “<table cellspacing=“1” cellpadding=“3”>
<td colspan=“6” bgcolor=”#999999" ><font color=“white”>" . $month . " Monthly Internet Sales Report
";
echo “
<td align=“center”> # Order Date |
|
Name |
| <td align=“right”>Charge ($)
”;
// check for march
do
{
echo “
<td align=“right” width=30>” . $count . " ";
echo “” . $row[‘order_date_no_time’] . " |
| ";
echo “” . $row[‘name’] . " |
| ";
echo “<td width=90 align=“right”>” . $row[‘cost’] . “
”;
$total_sales = $total_sales + $row['cost'];
$match++; // used later to show a match was made
$count++; // number rows
if ($count == 60 || $count == 120)
{
// deal with multipage table headers
}
} while($row = mysql_fetch_array($result)); // end DO-WHLE
if ($match == 0)
echo “
<td colspan=“6”>No matches.
”;
else
{
echo “
|
|
| <td colspan=“2” align=“right”>Total”;
echo “<td align=“right”>” . $total_sales . “
”;
}
mysql_close();
?>
[/php]
Thanks for all your time and help!