Hi guys! Gday'..i have a program of counting of votes..i want to add viewing_bycourse.php and viewing_bydepartment.php for those who are already voted..

done with listing of all users who are already voted so i want to show the list of users by course and by deparment.. i dont know if sorting is one way for that..

here's my query $sql=mysql_query("Select * from students where voted=1 order by course"); this qyery shows only the order of all courses from A-up to the end..i want that every user who are goin to vote,when they log into the system, their course will go to the by_course if they are HRM or CS or IT..

tnx if someone can help me to find out for this..

You need to explain your problem better.
As it is, You get all of the student sthat voted order listed by dept.
What else are you trying to do? It's not clear...

You need to explain your problem better.
As it is, You get all of the student sthat voted order listed by dept.
What else are you trying to do? It's not clear...

ok..in view_records.php, i had already the list of all users that had been voted..so that means there's an IT course, CS,HRM, BA etc..what i want is, i want to separate the list of voters according to their course..can you find an answer for that..? hope it will..

I'm sorry takeshi, I still don't understand;
Currently the query might yield a page like this:

Query of voters:
joe cs
bill cs
joan cs
Alex ba
Paco ba
Mary ba
Sue ba
etc...
This is voters with their coarse.
Perhaps if you make a psuedo page like above, it will clarify your point.
You might want to add a coarse on technical writing, too. LOL

$sql=mysql_query("Select * from students where voted=1 group by department order by course");
$sql=mysql_query("Select * from students where voted=1 group by course order by department");
$sql=mysql_query("Select * from students where voted=1 course=%s group by department order by name", $session['course']);

combinations of group by order by produce widely different and often interesting results
the last one, is unchecked, I always messup replaceable parameters in mysql please check the format at a reputable instruction site
%s is replaced by the content of $session

I'm sorry takeshi, I still don't understand;
Currently the query might yield a page like this:

Query of voters:
joe cs
bill cs
joan cs
Alex ba
Paco ba
Mary ba
Sue ba
etc...
This is voters with their coarse.
Perhaps if you make a psuedo page like above, it will clarify your point.
You might want to add a coarse on technical writing, too. LOL

oh ok..waht i want is say for example here..for viewing_bycourse,
viewby_IT.php
joan cs
carl cs
shiela cs
joseph cs
viewby_BA.php
joan ba
carl ba
shiela ba
joseph ba

so here in example,there's two page in viewing..you can view the list of voters by course such as BS or IT or etc..

$sql=mysql_query("Select * from students where voted=1 group by department order by course");
$sql=mysql_query("Select * from students where voted=1 group by course order by department");
$sql=mysql_query("Select * from students where voted=1 course=%s group by department order by name", $session['course']);

combinations of group by order by produce widely different and often interesting results
the last one, is unchecked, I always messup replaceable parameters in mysql please check the format at a reputable instruction site
%s is replaced by the content of $session

ok ill't try this one if it is work..tnx..

How about in viewby_IT.php, use this query:

$sql=mysql_query("Select * from students where (voted=1 AND coarse = 'cs')");

In viewby_BA.php use this query;

$sql=mysql_query("Select * from students where (voted=1 AND coarse ='ba')");

How about in viewby_IT.php, use this query:

$sql=mysql_query("Select * from students where (voted=1 AND coarse = 'cs')");

In viewby_BA.php use this query;

$sql=mysql_query("Select * from students where (voted=1 AND coarse ='ba')");

ok ill try this if it is work..tnx...

How about in viewby_IT.php, use this query:

$sql=mysql_query("Select * from students where (voted=1 AND coarse = 'cs')");

In viewby_BA.php use this query;

$sql=mysql_query("Select * from students where (voted=1 AND coarse ='ba')");

hmm tnx for this..! it works... :) now i know how to sort records..all i know is grouping and using order in sql query...tnx..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.