hi am beginner in php.. please help me..
rough explanation:
user will select orgname and the following code will get the orgname and import data from mssql. i wanted to filter those data according to groupname and count number of users access to the system in month basis according to date in logtime. (I simply print the output in code for checking purpose)
e.g the output will be :
count of logtime
groupname jan feb march....
A 3 1 2
B 1 4 5
is it possible to use SQL query on mssql_fetch_array or please suggest me a solution. thank you.
<?php
$variable=$_REQUEST['orgname'];
$database="ibase";
mssql_connect ("SQLEXPRESS", "testuser", "testuser123");
@mssql_select_db($database) or die( "Unable to select database");
$result = mssql_query( "SELECT COUNT(*) AS count, dbo.Reg_Group.RegID, dbo.Reg_Group.GroupName, dbo.Reg_Group.GroupID,
dbo.Reg_Group.UserType, dbo.Reg_Group.Domainid, dbo.Reg_Group.trialgroup, dbo.Reg_Group.orgid,
dbo.Reg_User.ID, dbo.Reg_User.UserID, dbo.Reg_User.atype,
dbo.Reg_Org.orgid AS orgzid, dbo.Reg_Org.orgname, dbo.Reg_Org.domainid AS domain, dbo.Reg_Org.create_date,
dbo.Reg_Org.usertype AS usertype1, dbo.LoginLog.logintime AS logtime
FROM dbo.Reg_Group INNER JOIN
dbo.Reg_User ON dbo.Reg_Group.RegID = dbo.Reg_User.RegID INNER JOIN
dbo.Reg_Org ON dbo.Reg_Group.orgid = dbo.Reg_Org.orgid INNER JOIN
dbo.LoginLog ON dbo.Reg_User.UserID = dbo.LoginLog.userid INNER JOIN
dbo.User_Login ON dbo.Reg_User.UserID = dbo.User_Login.UserID
WHERE (dbo.Reg_Org.usertype = 's') AND (dbo.Reg_Org.orgname ='$variable')
GROUP BY dbo.Reg_Group.RegID, dbo.Reg_Group.GroupName, dbo.Reg_Group.GroupID, dbo.Reg_Group.UserType,
dbo.Reg_Group.Domainid,
dbo.Reg_Group.trialgroup, dbo.Reg_Group.orgid, dbo.Reg_User.ID, dbo.Reg_User.RegID, dbo.Reg_User.UserID,
dbo.Reg_User.atype,
dbo.Reg_Org.orgid, dbo.Reg_Org.orgname, dbo.Reg_Org.domainid, dbo.Reg_Org.create_date, dbo.Reg_Org.usertype,
dbo.LoginLog.logintime" ) or die("query error");
$num_rows = mssql_num_rows($result);
print "There are $num_rows records.<P>";
print "<table width=200 border=1>\n";
while ($get_info = mssql_fetch_row($result)){
print "<tr>\n";
foreach ($get_info as $field)
print "\t<td><font face=arial size=1/>$field</font></td>\n";
print "</tr>\n";
}
print "</table>\n";
?>