Jump to content

Yuki

Members
  • Posts

    39
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Yuki's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. just did some work and got SELECT * FROM student_answer RIGHT OUTER JOIN choice ON (student_answer.choice_No = choice.choice_No) and (student_answer.question_ID = choice.question_ID) WHERE choice.question_ID = '2'; to work, it's not the full statement but I was just testing with outer join, i'll try your query now thanks EDIT: fenway thanks for your help but I don't think your query is looking for what it should do, which is my fault because I edited out the database structure link by accident, but thank you. I came to this conclusion: SELECT count(student_answer.choice_No) 'counted', choice.choice_No 'no', choice.choice_Desc 'desc' FROM student_answer RIGHT OUTER JOIN choice ON (student_answer.choice_No = choice.choice_No) and (student_answer.question_ID = choice.question_ID) WHERE choice.question_ID = '2' GROUP BY choice.choice_No ORDER BY choice.choice_No; that returns counted no desc 0 1 Indigo 1 2 Blue 0 3 Orange 0 4 internet0 5 asdad 0 6 dasdasd 2 7 asdadsdd which is what I was after, thanks.
  2. so I need to use ON instead of using? to gluck: SELECT count(student_answer.choice_No) 'counted', choice_No 'no', choice.choice_Desc 'desc' FROM student_answer LEFT OUTER JOIN choice USING (choice_No) WHERE student_answer.question_ID = '2' and choice.question_ID = '2' GROUP BY choice.choice_No ORDER BY choice.choice_No; didn't work either EDIT: SELECT count(student_answer.choice_No) 'counted', choice.choice_No 'no', choice.choice_Desc 'desc' FROM student_answer LEFT JOIN choice ON choice.choice_No IS NULL or choice.choice_No = student_answer.choice_No WHERE student_answer.question_ID = '2' and choice.question_ID = '2' GROUP BY choice.choice_No ORDER BY choice.choice_No tried this also
  3. SELECT count(student_answer.choice_No) 'counted', choice_No 'no', choice.choice_Desc 'desc' FROM student_answer LEFT JOIN choice USING (choice_No) WHERE student_answer.question_ID = '3' and choice.question_ID = '3' or choice.choice_No IS NULL GROUP BY choice.choice_No ORDER BY choice.choice_No; Is what I'm at so far with fenways suggestion.. it's not working however
  4. I solved the above problem by running the same query twice and once with limit 1 and descending to get the most chosen. However I have another problem, how do I get it to return choices that weren't chosen too?
  5. SELECT count(student_answer.choice_No) , choice_No FROM student_answer LEFT JOIN choice USING (choice_No) WHERE student_answer.question_ID = "2" and choice.question_ID = "2" GROUP BY choice.choice_No ORDER BY choice.choice_No; this returns me the choice an number of times it was chosen, how do I also include the MAX count of student_answer.choice no?
  6. solved it myself eventually thanks anyway
  7. I apologise please log in with the information: id: admin password: istrator
  8. I need to delete from 3 tables module question choice I need to delete a module, all it's questions, and all that questions choices. module is linked to question with module_Code, question is linked to choice with question_ID! Is this possible in one query?
  9. http://shahinrostami.com/webdevass2/admin.php?page=1 Make the window smaller if the content doesn't overflow, and scroll to the bottom, you can see the central container div just ends, how do I get it to stretch?
  10. Yuki

    mysql or die

    previous data that has been entered, it's a list of questions with a form on the page to add more EDIT: Solved, thanks a lot everyone. There was some code after that was interfering that I removed.
  11. Yuki

    mysql or die

    Hi thanks but that tells me it's succeeded even if it hasn't!
  12. Yuki

    mysql or die

    http://shahinrostami.com/webdevass2/question.phps is where the full code for this page is if you need to see
  13. Yuki

    mysql or die

    if(isset($_POST['submit'])) { $question_Desc = $_POST['question_Desc']; $question_EndDate = $_POST['question_EndDate']; $question_Week = $_POST['question_Week']; $query = "INSERT INTO question (question_Desc, question_Week, question_Correct_Answer, question_EndDate, module_Code) VALUES ('$question_Desc', $question_Week, 0, '$question_EndDate', '$module')"; $echo = "Failed adding the question to the database"; mysql_query($query)or die("<script type='text/javascript'> var divid = document.getElementById('notify'); divid.style.display = 'block'; divid.innerHTML = '".$echo."'; </script>"); // the code you want to echo // script to display it $echo = "Succeeded adding the question to the database"; // script to display it echo "<script type='text/javascript'> var divid = document.getElementById('notify'); divid.style.display = 'block'; divid.innerHTML = '".$echo."'; </script>"; } The question is, when the mysql fails, it goes on to die(), and then doesn't continue print below (which is html) I need an alternative to die for catching mysql errors
  14. if the sql fails and it prints out what's int die('') it doesn't proceed through the rest of the script, if it fails I want it to just show a notification saying "failed" but also finish the script (pulls out data from db and shows it) Any way?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.