I've included all the applicable code for a date range search that I created. It worked fine until I wanted to pull some data from another table into the recordset (indicated by "-->"). Now it's not working at all. Any help appreciated.
Code: Select all
<?php
$gm_sql_server = "localhost";
$gm_sql_username = "root";
$gm_sql_password = "";
$gm_sql_database = "something";
$gm_db = mysql_connect($gm_sql_server, $gm_sql_username, $gm_sql_password) or gm_die("Unable to connect to database. Please check your gm MySQL server, username and password configuration options.");
mysql_select_db($gm_sql_database, $gm_db) or gm_die("Unable to select the database. Please check your gm MySQL database configuration option.");
$sy = $_REQUESTї"startYear"];
$sm = $_REQUESTї"startMonth"];
$sd = $_REQUESTї"startDate"];
$ey = $_REQUESTї"endYear"];
$em = $_REQUESTї"endMonth"];
$ed = $_REQUESTї"endDate"];
$repid = $_REQUESTї"repid"];
$start_date = $sy."-".$sm."-".$sd;
$end_date = $ey."-".$em."-".$ed;
$result = mysql_query ("Select * from orders WHERE DATE_FORMAT(nowtime, '%Y-%m-%d') BETWEEN DATE_FORMAT('$start_date', '%Y-%m-%d') AND DATE_FORMAT('$end_date', '%Y-%m-%d') and repID='$repid'", $gm_db);
//$product = mysql_query("select product_name.products, product_id.products, fk_product.orders from products, orders where fk_product.orders = product_id.products");
if ($result == "") {
echo "no results";
exit;
}
elseif (!$result){
echo "no results";
exit;
}
else
{
echo <<<EOF
<TABLE width="100%" BORDER=1 bordercolor="#eeeeee"><tr><td colspan="6">Searching from $start_date to $end_date.</td></tr>
<TR><td><b>Name</b></td><td><b>Sales Agent ID</b></td><td><b>Product</b></td><td><b>Date of Sale</b></td><td><b>Address</b></td><td><b>Phone</b></td></TR>
EOF;
while ($item = mysql_fetch_object($result))
{
-->$product_orders = $item->fk_product;
--> $product = mysql_query("select p.product_name, p.product_id, o.fk_product from orders o, products p where p.product_id=$product_orders", $gm_db);
--> $product_item = mysql_fetch_object($product);
echo "<TR><TD>$item->firstname $item->lastname</TD><TD>$item->repID</TD><TD>$product_item->product_name</TD><TD>$item->nowtime</TD><TD>$item->address1<br />$item->address2<br />$item->city, $item->state $item->zip</TD><TD>$item->dayphone</TD></TR>";
}
}
echo <<<EOF
</table>
EOF;
mysql_close($gm_db);
?>feyd | USE FORMATTING TAGS