0

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..

4
Contributors
12
Replies
15
Views
7 Years
Discussion Span
Last Post by test1234qsr
Featured Replies
  • [code=php]$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']);[/code]combinations of group by order by produce widely different and often interesting results … Read More

  • 1
    JRM 107   7 Years Ago

    How about in viewby_IT.php, use this query: [CODE] $sql=mysql_query("Select * from students where (voted=1 AND coarse = 'cs')"); [/CODE] In viewby_BA.php use this query; [CODE] $sql=mysql_query("Select * from students where (voted=1 AND coarse ='ba')"); [/CODE] Read More

0

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...

0

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..

Edited by takeshi: n/a

0

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

1
$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

Edited by almostbob: n/a

0

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..

0
$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..

1

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')");
0

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...

0

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..

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.