rainman89
I cant find the any key..
- Local time
- Today, 17:55
- Joined
- Feb 12, 2007
- Messages
- 3,015
Im pretty sure im doing this wrong, but I cant think of any other way to do it.
My issue is I have a link table where the user ID , date and approval are entered in to the table to give me a request ID.
I would then use the requestID and add into another table along with many other things.
I am trying to get the max requestID from a table based on the userID and date, but for some reason, its not returning anything.
My question is, can I do multiple queries off of the same connection? or do I have to close the connection everytime and then reconnect to run a new query?
Any help would be appreciated.
My issue is I have a link table where the user ID , date and approval are entered in to the table to give me a request ID.
I would then use the requestID and add into another table along with many other things.
I am trying to get the max requestID from a table based on the userID and date, but for some reason, its not returning anything.
My question is, can I do multiple queries off of the same connection? or do I have to close the connection everytime and then reconnect to run a new query?
Code:
$conn=odbc_connect('database','','');
if (!$conn)
{exit("Connection Failed: " . $conn);
}
$insert="INSERT INTO tblRequest (EmployeeID, RequestDate, RequestApproval) VALUES ($empID,'$reqDate',1)";
echo $insert;
$rs=odbc_exec($conn,$insert);
if (odbc_error())
{
echo odbc_errormsg($conn);
}
$requestID="SELECT Max(tblRequest.RequestID) AS MaxOfRequestID, tblRequest.EmployeeID, tblRequest.RequestDate FROM tblRequest GROUP BY tblRequest.EmployeeID, tblRequest.RequestDate HAVING (((tblRequest.EmployeeID)=$empID) AND (tblRequest.RequestDate)=$reqDate)";
echo $requestID;
$rs2=odbc_exec($conn,$requestID);
while (odbc_fetch_row($rs2))
{
$reqID = odbc_result($rs2,"MaxOfRequestID");
}
echo $reqID;
if (odbc_error())
{
echo odbc_errormsg($conn);
}
Any help would be appreciated.