Jump to content


  • Posts

  • Joined

  • Last visited


Profile Information

  • Gender
    Not Telling

xxreenaxx1's Achievements

Regular Member

Regular Member (3/5)



  1. SELECT p.orderid, p.updated, p.origsalesman, p.salesman, p.status, p.profit, p.product, p.orderdate, o.price FROM printersales p, printers pr, orderdetail o WHERE o.productid = pr.productid AND p.orderid = o.orderid AND p.updated > '2011-08-5 00:00:01' This is my code and when I do this query without it gives me 29 results but if I do the query shown above it gives me 24 result so I am missing few field and not sure why. Any idea why its doing this? Do I have an error on my code??
  2. I am printing question id and corect answers and incorrect one. Example: Questionid =8 Incorrect Incorrect Incorrect Correct Correct Incorrect This will be repeated for other question id. Now I would like to count total answers. In my example it will be 6. I would like to count the correct one so that will be 2. And print 2 as outcome. So far I have $sqlll=questionid(); while($infoo = mysql_fetch_array( $sqlll)) { echo "<hr><br><strong>{$infoo['Que_ID']}</strong><br />\n"; $_Session1=$infoo['Que_ID']; $que=question($_Session1); while($infooo = mysql_fetch_array( $que)) { $answer1 = $infooo['Que_Answer1'] == $infooo['Ans_Answer1']; $answer2 = $infooo['Que_Answer2'] == $infooo['Ans_Answer2']; $answer3 = $infooo['Que_Answer3'] == $infooo['Ans_Answer3']; $answer4 = $infooo['Que_Answer4'] == $infooo['Ans_Answer4']; if ( $answer1 && $answer2 && $answer3 && $answer4) { echo ('<b><p style="color: green; text-align: left"> Correct </p></b>'); $scoree = $scoree + 1; } else { echo ('<br><b><p style="color: red; text-align: left"> Incorrect </p></b></br>'); $intt= $intt +1; } }
  3. My connection wasnt correct. That was my error Thanks
  4. I have tried to run my code and it works. I am not getting any error message but when I checked my database nothing was added. <?php session_start(); include '../Database/connection.php'; if ($_FILES["file"]["error"] > 0) { echo "Error: " . $_FILES["file"]["error"] . "<br />"; } $filename = $_FILES["file"]["tmp_name"]; $fd = fopen ($filename, "r"); $data = fread ($fd,filesize ($filename)); fclose ($fd); $delimiter = "\n"; $output = explode($delimiter, $data); foreach($output as $var) { $tmp = explode(".", $var); $question = $tmp[0]; $choice1 = $tmp[1]; $choice2 = $tmp[2]; $choice3 = $tmp[3]; $choice4 = $tmp[4]; $answer1 = $tmp[5]; $answer2 = $tmp[6]; $answer3 = $tmp[7]; $answer4 = $tmp[8]; $sql = "INSERT INTO question SET Que_Question='$question', Que_Choice1='$choice1', Que_Choice2='$choice2', Que_Choice3='$choice3', Que_Choice4='$choice4', Que_Answer1='$answer1', Que_Answer2='$answer2', Que_Answer3='$answer3', Que_Answer4='$answer4', Tes_ID='$_SESSION[Tes_ID]'"; mysql_query($sql); } ?> My text file holds
  5. I dont know how implement that?? :S
  6. oh.. I want to check if the user has already taken a question. This is the reason why I am compairing a.Que_ID = q.Que_ID. So if the person has taken the exam, this will not be displayed.
  7. I am trying to run this query on a webpage but I am getting an error. So I tested this on mysql and this is giving me error as well. IF EXISTS (SELECT * FROM user u, subject s, test t, question q, answer a WHERE u.Use_ID = 1 AND t.Sub_ID = 1 AND s.Sub_ID = t.Sub_ID AND q.Que_ID = a.Que_ID) am I doing anything wrong.
  8. Nope. I tired few other ways as well. Nothing works. This is the error message I am getting I am using function for this method. And on line 3 I have function comple($Test_ID){
  9. How can you make these two delete function as one. DELETE FROM test WHERE Tes_ID= 11; DELETE FROM question WHERE Tes_ID=11;
  10. I am trying to use delete function but not sure if I can have something like this. If not can someone suggest something ("DELETE FROM answer (Ans_Answer1, Ans_Answer2, Ans_Answer3, Ans_Answer4, Que_ID, Use_ID) VALUES ('1', '1', '0', '0', '1', '1')")
  11. I am writing a program which checks the results for a student. If the results are same as the ones inside the table, then correct message is printed. If the results are not the same then the right answer should be printed as well as wrong message and the answer the user selected. I am using checkbox to let the user choose the answers and this is saved on to the database. I need to retrieve this and compare this with the original table. my tables are Answer: ,Ans_ID,Ans_Answer1, Ans_Answer2, Ans_Answer3, Ans_Answer4,Que_ID Question:Que_ID, Que_Answer1, Que_Answer2, Que_Answer3, Que_Answer4 Answer table is what the user enters and the question table is the one with the correct answer. SELECT Ans_ID, IF(answer.Ans_Answer1 = question.Que_Answer1 AND answer.Ans_Answer1 = question.Que_Answer1 AND answer.Ans_Answer1 = question.Que_Answer1 AND answer.Ans_Answer1 = question.Que_Answer1, "Correct","Wrong") AS result FROM answer LEFT JOIN question ON answer_id = question_id can someone give me ideas, not asking for you to write the code for me. just help me out as I am stuckk
  12. I have a code that works but it wont add the data to my database. It says the data has been added but the actual data is not actually added. I have checked through this code to see any errors but I cant find any. Can someone help me $sqll= takeanexam($_SESSION['username1'], $_SESSION['ssubject'], $_SESSION['smodule']); // mysql_data_seek(sqll, 0); while($info = mysql_fetch_array( $sqll )) { $questionId = $info['Que_ID']; $choice = array(); for ($i =1; $i < 5; $i++) { if (empty($_POST['choice'][$questionId][$i])) { $choice[$i] = 0; } else { $choice[$i] = 1; } } $username= $_SESSION['username1']; mysql_query("INSERT INTO answer (Ans_Answer1, Ans_Answer2, Ans_Answer3, Ans_Answer4, Que_ID, Use_ID) VALUES ({$choice[1]}, {$choice[2]}, {$choice[3]}, {$choice[4]}, $questionId, $username)"); }
  13. Nope, its not sorted. This is what I get when I print
  • 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.