General Community > Scripting Help

Need some help with a query

(1/1)

hungarianguy:
i need some help with a query. i have developed a mod that lists all students from classes. so far so good. now i want to check users emails and see who has used the same email for differnt clases. it works good but i have some issue with the pagination. i would love some help. here is my code


--- Code: ---function list_students($start, $items_per_page, $sort)
{
global $smcFunc, $scripturl;

$result = $smcFunc['db_query']('', '
            SELECT name, email, COUNT(email)
                FROM {db_prefix}students_list
GROUP BY email
                HAVING COUNT(email) > 1
ORDER BY {raw:sort}
        LIMIT {int:start}, {int:per_page}',
array(
'sort' => $sort,
            'start' => $start,
        'per_page' => $items_per_page,
)
);

    $students = array();

while ($row = $smcFunc['db_fetch_assoc']($result))
{
$students[] = array(
'name' => $row['name'],
'email' => $row['email'],
);
}

return $students;

$smcFunc['db_free_result']($result);
}

//Count all entries for the pagination.
function list_countstudents()
{
global $smcFunc;

$result = $smcFunc['db_query']('', '
SELECT member_ip, COUNT(*) AS ipCount
FROM {db_prefix}students_list
HAVING ipCount > 1
',
array(
     
)
);

list ($students) = $smcFunc['db_fetch_row']($result);

$smcFunc['db_free_result']($result);

return $students;
}
--- End code ---

Navigation

[0] Message Index

Go to full version