So I am trying to display answers to a survey but first I want to separate the USER ids from each other. Right now Answers are stored similar to this....
SGpID, SGresult, SGFACemail
Essentially, I want to display a button for each Unique ID. So if I have 5 answers with an ID of 10, and 5 answers with an ID of 12. I want buttons saying "Results for ID 10" and "Results for ID 12".
What it is currently doing is displaying EVERY iteration where the select statement matches so essentially every answer... no bueno.
My thought was that I would go through a for each loop to separate the results and do something along the lines of...
"Each time SGpID is different", display a new button with that new SGpID.
I am just not sure really how to write it out. Here is what I have so far for the statement.
$query_db = ("SELECT SGpID FROM SGresult WHERE SGFACemail = '$email'");
$result = mysql_query($query_db) or die(mysql_error());
while ($row = mysql_fetch_assoc($result)) {
//insert for each loop here?
echo $row['SGpID'];
}
Thanks as always for any help or ideas on this one!
SGpID. You might want to do something like this:SELECT SGpID, count(SGpID) as c FROM SGresult WHERE SGFACemail = '$email' GROUP BY SGpID- then you can output it in yourwhile-loop like this:echo "Results for {$row['SGpID']}: {$row['c']};