MySQL Forums
Forum List  »  PHP

PHP + MySQL results
Posted by: William Dalladay-Elliott
Date: July 20, 2005 06:30AM

Heya, got a little problem... I'm running a query to select data from 3 tables:

SELECT q.qID, q.qQuestion, a.aAnswer from qQAnswers s, qAnswers a, qQuestions q WHERE s.qaAID = a.aID AND q.qID = s.qaQID ORDER BY q.qID

When I do this via the console, it prints the following data:

mysql> SELECT q.qID, q.qQuestion, a.aAnswer from qQAnswers s, qAnswers a, qQuestions q WHERE s.qaAID = a.aID AND q.qID = s.qaQID ORDER BY q.qID;
+-----+------------------------------------------------------------------------------------------------------------+-----------+
| qID | qQuestion | aAnswer |
+-----+------------------------------------------------------------------------------------------------------------+-----------+
| 1 | Does senior management have regular, direct interaction with front-line employees and customers? | Always |
| 1 | Does senior management have regular, direct interaction with front-line employees and customers? | Sometimes |
| 1 | Does senior management have regular, direct interaction with front-line employees and customers? | Rarely |
| 2 | Do you experience 'silo' thinking and lack of coordination between departments? | Often |
| 2 | Do you experience 'silo' thinking and lack of coordination between departments? | Sometimes |
| 2 | Do you experience 'silo' thinking and lack of coordination between departments? | Rarely |
| 3 | Are customer-facing staff trained in how their performance contributes to corporate financial targets? | Yes |
| 3 | Are customer-facing staff trained in how their performance contributes to corporate financial targets? | No |
| 4 | Is your organisation better at analysis then action? | Yes |
| 4 | Is your organisation better at analysis then action? | Same |
| 4 | Is your organisation better at analysis then action? | No |
| 5 | Is there an overall view of all the initiatives being undertaken across the organisation? | Yes |
| 5 | Is there an overall view of all the initiatives being undertaken across the organisation? | No |
| 6 | Have important initiatives been delayed by 'office politics' getting in the way? | Yes |
| 6 | Have important initiatives been delayed by 'office politics' getting in the way? | No |
| 7 | Are some people in the organisation 'snowed under' with initiatives? | Yes |
| 7 | Are some people in the organisation 'snowed under' with initiatives? | No |
| 8 | Is the progress of each initiative tracked until it makes an impact on the bottom-line? | Yes |
| 8 | Is the progress of each initiative tracked until it makes an impact on the bottom-line? | No |
| 9 | Are the options being considered for the future success of the company sufficiently radical and ambitious? | Yes |
| 9 | Are the options being considered for the future success of the company sufficiently radical and ambitious? | No |
| 10 | Does the organisation have too many meetings? | Yes |
| 10 | Does the organisation have too many meetings? | No |
| 11 | Is there a clear ranking of initiatives, with less valuable ones being stopped or delayed? | Yes |
| 11 | Is there a clear ranking of initiatives, with less valuable ones being stopped or delayed? | No |
| 12 | Has there been confusion over who is responsible for the success of initiatives? | Often |
| 12 | Has there been confusion over who is responsible for the success of initiatives? | Sometimes |
| 12 | Has there been confusion over who is responsible for the success of initiatives? | Rarely |
| 13 | Before a management meeting are all the decisions to be taken known by the participants? | Yes |
| 13 | Before a management meeting are all the decisions to be taken known by the participants? | No |
| 14 | After the meeting is and action plan circulated to all participants? | Mostly |
| 14 | After the meeting is and action plan circulated to all participants? | Sometimes |
| 14 | After the meeting is and action plan circulated to all participants? | Rarely |
| 15 | Are action plans sufficiently detailed to be tracked weekly? | Yes |
| 15 | Are action plans sufficiently detailed to be tracked weekly? | No |
| 16 | Do managers have their own pet projects which tend to take precedence for time and resources? | Yes |
| 16 | Do managers have their own pet projects which tend to take precedence for time and resources? | No |
| 17 | Are projects completed on time? | Mostly |
| 17 | Are projects completed on time? | Sometimes |
| 17 | Are projects completed on time? | Rarely |
| 18 | Is sufficient resource allowed allocated to each project? | Yes |
| 18 | Is sufficient resource allowed allocated to each project? | No |
| 19 | Does winning market share drive most performance improvement initiatives? | Yes |
| 19 | Does winning market share drive most performance improvement initiatives? | No |
| 20 | Are implementation issues considered before final decisions are taken? | Yes |
| 20 | Are implementation issues considered before final decisions are taken? | No |
+-----+------------------------------------------------------------------------------------------------------------+-----------+
46 rows in set (0.02 sec)

When I get it to output in PHP, it runs prints the answers per row, and with the question repeated... I want it to that it outputs in this form:

<question id> <question> <answer> <answer> <answer>
not
<question id> <question> <answer>
<question id> <question> <answer>
<question id> <question> <answer>

How would I go about doing this? I can't remember how to reference each row instead of just straight outputting... could anyone help?

Many Thanks,
~ Willmo

Options: ReplyQuote


Subject
Written By
Posted
PHP + MySQL results
July 20, 2005 06:30AM
July 21, 2005 12:15AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.