This query:
$query = "SELECT * FROM activity, customers WHERE activity.UserID=customers.UID AND
$qdate ORDER BY activity.thisDateField";
Yields 22 records when I perform it at the SQL prompt.
I'm trying to write those results into a temporary table. But, it's not working. It's only pulling one record and writing it to the database. I'm not sure I understand why. Here's the relevant code:
$qdate = "(month(timestamp) = month(now()) and dayofmonth(timestamp) = (dayofmonth(now())-1) and year(timestamp)=year(now()))";
$query = "SELECT * FROM activity, customers WHERE activity.UserID=customers.UID AND
$qdate ORDER BY activity.thisDateField";
$result = @mysql_query ($query) or die( mysql_error() );
while ($row = @mysql_fetch_array ($result, MYSQL_ASSOC)) {
$UserID = $row['UserID'];
$item = $row['item'];
$ts = $row['thisDateField'];
$src = $row['store'];
$query = "INSERT INTO temporary_table_1 (UserID, item, thisDateField, store)
VALUES ('$UserID', '$item', '$ts', '$src')";
$result = mysql_query($query);
}