at this moment the code listed below, as part of using it within whmcs
{php}
$cleansed_uid = (int) $_SESSION['uid'];
$query = "SELECT * FROM tblhosting WHERE userid=".mysql_escape_string($cleansed_uid)." AND (domainstatus='Active') AND (packageid='10' OR packageid='2' OR packageid='30' OR packageid='40' OR packageid='44' OR packageid='45' OR packageid='104' )";
$result = mysql_query($query);
$total = mysql_num_rows($result);
while ($data = mysql_fetch_array($result)) {
echo "$total";
}
{/php}
but my results is 22, instead of 2, or 333 instead of 3 query results
what i'm trying to do is, to fetch the active services, based upon userid and to match with package x y q, and to display as total active services, based on the packages, as you can see i'am able to fetch the info, just the total is wrong, please point me to the right way to do it. thanks.
while ($data = mysql_fetch_array($result)) {
$total = mysql_num_rows($result);
change to
$total = mysql_num_rows($result);
while ($data = mysql_fetch_array($result)) {
And stand outside the while line:
echo "$total";
Total:
$cleansed_uid = (int) $_SESSION['uid'];
$query = "SELECT * FROM tblhosting WHERE userid=".mysql_escape_string($cleansed_uid)." AND (domainstatus='Active') AND (packageid='1' OR packageid='20' OR packageid='30' OR packageid='40' OR packageid='44' OR packageid='45' OR packageid='104' )";
$result = mysql_query($query);
$total = mysql_num_rows($result);
while ($data = mysql_fetch_array($result)) {
$id = $data["id"];
$domain = $data["dedicatedip"];
}
echo "$total";