Guest User

Untitled

a guest
Jul 25th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.30 KB | None | 0 0
  1. this is what i have thus far
  2.  
  3.  
  4. <?php
  5. @session_start();
  6.  
  7. $hostname = "localhost";
  8. $username = "root";
  9. $password = "hayden";
  10. $database = "ecng3020";
  11.  
  12.  
  13.  
  14. $con = mysql_connect("$hostname","$username","$password");
  15. if (!$con)
  16. {
  17. die('Could not connect: ' . mysql_error());
  18. }
  19. mysql_select_db("$database", $con);
  20.  
  21. $q="SELECT * FROM rules Where type ='course_option' ";
  22. if ($result_2=mysql_query($q))
  23. {
  24. echo"nice";
  25. }
  26. else
  27. {
  28. echo"shit";
  29. }
  30.  
  31. while($row = mysql_fetch_assoc($result_2))
  32. {
  33. extract($row);
  34. //echo "<p>$parameters</p>";
  35. $e=explode(",",$parameters);
  36. //print_r($e);
  37. $_SESSION['parm']=$e;
  38.  
  39. //$id=$_SESSION['username'];
  40.  
  41. //$_SESSION['courses']=$_POST['coursecode_1'];
  42.  
  43. //print_r($_SESSION['courses']);
  44. @$code= $e;
  45.  
  46. if( is_array($code))
  47. {
  48. //$sum= array();
  49.  
  50. while (list ($key, $val) = each ($code))
  51. {
  52. echo $val;
  53. $w="SELECT * FROM student_course WHERE course_status='pass' AND course_code='$val' AND
  54. id_no=806000169";
  55.  
  56. if ($result1=mysql_query($w))
  57. {
  58. echo"nice";
  59. }
  60. else
  61. {
  62. echo"shit";
  63. }
  64.  
  65. while($row1 = mysql_fetch_assoc($result1))
  66. {
  67. extract($row1);
  68. echo "<p>$course_status</p>";
  69. echo "<p>$course_code</p>";
  70. //$first=array();
  71. $first[]=$course_code;
  72. //echo $y;
  73. //echo "<p>hi</p>";
  74. //print_r($first);
  75.  
  76.  
  77. }
  78. }
  79. }
  80.  
  81.  
  82.  
  83. print_r($first);
  84. $_SESSION['first']=$first;
  85.  
  86. }
  87.  
  88.  
  89.  
  90.  
  91. function form()
  92. {
  93. $hostname = "localhost";
  94. $username = "root";
  95. $password = "hayden";
  96. $database = "ecng3020";
  97.  
  98.  
  99. $courses_options = "";
  100. $con = mysql_connect("$hostname","$username","$password");
  101. if (!$con)
  102. {
  103. die('Could not connect: ' . mysql_error());
  104. }
  105. mysql_select_db("$database", $con);
  106.  
  107. $courses_options .= "<option value=\"NULL\">Course :</option>\n";
  108. $try="Select course_code,course_name FROM courses";
  109. $rsrcResult = mysql_query($try);
  110. $courses_options .= "<select name=coursecode_1[] size=4 multiple>";
  111. while($row = mysql_fetch_row($rsrcResult)) {
  112.  
  113. $strA=$row[0];
  114. $strB=$row[1];
  115.  
  116.  
  117.  
  118.  
  119. $courses_options .= "<option value=\"$strA\">$strB</option>\n";
  120. }
  121.  
  122. $courses_options .= "</select>";
  123.  
  124.  
  125. echo <<<EOB
  126. <form method=post action=''>
  127. <p>$courses_options</p>
  128.  
  129.  
  130. <p>
  131. <input type="submit" name="submit" value="Submit" />
  132. <input type="reset" name="Reset" value="Cancel" />
  133. </p>
  134. </form>
  135. EOB;
  136.  
  137. }
  138.  
  139. form();
  140.  
  141.  
  142. if ($_POST['submit'] == 'Submit')
  143. {
  144.  
  145. $hostname = "localhost";
  146. $username = "root";
  147. $password = "hayden";
  148. $database = "ecng3020";
  149.  
  150. $con = mysql_connect("$hostname","$username","$password");
  151. if (!$con)
  152. {
  153. die('Could not connect: ' . mysql_error());
  154. }
  155.  
  156. mysql_select_db("$database", $con);
  157.  
  158. //$id=$_SESSION['username'];
  159. @$code= $_POST['coursecode_1'];
  160. $_SESSION['courses']=$_POST['coursecode_1'];
  161.  
  162. //print_r($_SESSION['courses']);
  163.  
  164.  
  165. if( is_array($code))
  166. {
  167. //$sum= array();
  168.  
  169. while (list ($key, $val) = each ($code))
  170. {
  171. //echo $val;
  172. //$second[]=$_POST['coursecode_1'];
  173. //print_r($_POST['coursecode_1']);
  174. $_SESSION['second']=$_POST['coursecode_1'];
  175. }
  176. }
  177. }
  178.  
  179. $new=array_merge($_SESSION['second'],$_SESSION['first']);
  180. print_r($new);
  181.  
  182.  
  183. $hostname = "localhost";
  184. $username = "root";
  185. $password = "hayden";
  186. $database = "ecng3020";
  187.  
  188.  
  189.  
  190. $con = mysql_connect("$hostname","$username","$password");
  191. if (!$con)
  192. {
  193. die('Could not connect: ' . mysql_error());
  194. }
  195. mysql_select_db("$database", $con);
  196.  
  197.  
  198. $q="SELECT * FROM rules Where type ='course_option' AND label='comms courses' ";
  199. if ($result_2=mysql_query($q))
  200. {
  201. echo"nice";
  202. }
  203. else
  204. {
  205. echo"shit";
  206. }
  207.  
  208. ($row = mysql_fetch_assoc($result_2))
  209.  
  210. extract($row);
  211. //echo "<p>$parameters</p>";
  212. $o=explode(",",$parameters);
  213. //print_r($e);
  214.  
  215.  
  216.  
  217.  
  218. for ($i=0;$i<count($new);$i++)
  219. {
  220. if ($new[$i]==$o[$i])
  221. {
  222. echo "<p>option complete</p>";
  223. }
  224. }
  225. ?>
Add Comment
Please, Sign In to add comment