I am bug-eyed from trying to figure out what I'm doing wrong here.
I cannot get results from this query to save my life. I even tried copying and pasting code from a query that IS working, then changing the details, but to no avail.
This query produces only the $orderdate result - nothing else:
//Define query
$query = "SELECT * FROM orders, Login_users WHERE orders.date = '$selectdate' ORDER BY orders.order_no ASC";
$r = mysql_query ($query);
$row = mysql_fetch_assoc($r);
//Convert order date format
$date = $row['date'];
$date_arr = explode('-', trim($date));
$order_date = ($date_arr[1].'-'.$date_arr[2].'-'.$date_arr[0]);
echo "<b>Orders Placed on: $orderdate</b><br /><br />";
// Run query
if ($r = mysql_query ($query)) {
// Retrieve and print every record
while ($row = mysql_fetch_array ($r)) {
echo "{$row['lender_name']}<br />
Order No. {$row['order_no']}<br /><br />
{$row['collateral_owner']}<br />
{$row['collateral_address']}<br />
{$row['collateral_city']}, {$row['collateral_state']} {$row['collateral_zip']}<br />
Loan No.: {$row['loan_no']}<br />
<hr noshade size="1" />";
}
} else { // Query didn't run.
die ('<p>Could not retrieve the data because: <b>' . mysql_error() . "</b>. The query was $query.
Please report this error to Company Name.</p>");
} // End of query IF.
mysql_close(); // Close the database connection.
$query = "SELECT * FROM orders, Login_users WHERE Login_users.lender_name = '$selectLenders' AND orders.userid = Login_users.userid ORDER BY orders.order_no DESC";
The userid field is the common field between the two tables.
I have been able to generate numerous reports by using the basic query format that I first posted - it's just this one "results by date" query that has me stumped.
Now I have to admit to you how noob I still am.
I haven't done this, because I'm not sure how. So on the form that is being submitted I tried this after the query:
From this I gather that something in the query is totally wrong, because 22 records should be produced. Is this right, or do I get demoted to noob again?
Well.. echoing the result from mysql_query, if executed correctly, should print "Resource #" followed by a number, so it looks like it's performing correctly. I would assume $rows is the result of a mysql_num_rows call, so it looks right..