Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php][MySQL] System ocen (szkolnych) - problem
PaKoS
post
Post #1





Grupa: Zarejestrowani
Postów: 28
Pomógł: 0
Dołączył: 24.03.2006

Ostrzeżenie: (0%)
-----


Witam,
otóż buduję podserwis dla pewnej witryny szkolnej
w którym każdy będzie mógł po rejestracji zapisywać swoje oceny z poszczególnych przedmiotów.

Przedmioty są zdefiniowane od początku i nie ma możliwości ich usuwanie czy edycji.
Dla każdego użytkownika po rejestracji tworzy się nowa tabela w bazie
w której mamy jak na razie dwie kolumny o nazwach Przedmiot i Oceny.
W kolumnie Przedmiot mamy w poszczególnych wierszach nazwy przedmiotów a w kolumnie Oceny odpowiadające im oceny zapisane tak:
(np.) 1,2,3,5,2,4,6,3,5,2
Mój problem polega na tym, że nie mam pojęcia jak zaprojektować układ tabeli tak, aby można było dowolną ocenę usunąć, zmienić, dodać nową a także obliczyć średnią ocen dla każdego przedmiotu.
Bo nie wiem co można zrobić z polem "1,2,3,5,2,4,6,3,5,2".
Myślałem o tworzeniu osobnych kolumn dla każdej oceny ale jak wtedy kontrolować nazwy tych kolumn i jak je wybierać?
(Oczywiście układ tabeli który podałem jest przykładowy, taki jaki zrobiłem na tą chwilę ale nic z tego zrobić mi się nie udało)

Proszę o porady,
pzdr,
PaKoS
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
PaKoS
post
Post #2





Grupa: Zarejestrowani
Postów: 28
Pomógł: 0
Dołączył: 24.03.2006

Ostrzeżenie: (0%)
-----


robię, robię i natrafiam na kolejny problem...
układ tabeli w bazie sql jest taki:
(IMG:http://oceny.slowak.kom.pl/img/tabela.jpg)

aż do 30 wierszy (ocen)
zrobiłem po prostu możliwość dodania do 30 ocen.
pytanie brzmi:
jak dla każdego wiersza stworzyć przycisk DODAJ OCENE (w niżej podanym kodzie to przycisk +) który będzie dodawał ją automatycznie w kolejnej pustej kratce?

Oto mój kod pliku view.php wyświetlającego oceny:
  1. <?php
  2.  
  3. $connection = mysql_connect("HOST", "USER", "HASŁO") 
  4. or die ("Nie można połączyć się z bazą SQL");
  5.  
  6. $db = mysql_select_db("BAZA_DANYCH", $connection) 
  7. or die ("Nie można wybrać bazy SQL");
  8.  
  9. $queries = array(); 
  10. $queries[] = "SELECT Biologia FROM oceny_user1";
  11. $queries[] = "SELECT Biologia FROM oceny_user1";
  12. $queries[] = "SELECT Fizyka FROM oceny_user1";
  13. $queries[] = "SELECT Geografia FROM oceny_user1";
  14. $queries[] = "SELECT Historia FROM oceny_user1";
  15. $queries[] = "SELECT JAngielski FROM oceny_user1";
  16. $queries[] = "SELECT JNiemiecki FROM oceny_user1";
  17. $queries[] = "SELECT JPolski FROM oceny_user1";
  18. $queries[] = "SELECT Matematyka FROM oceny_user1";
  19. $queries[] = "SELECT Religia FROM oceny_user1";
  20. $queries[] = "SELECT WF FROM oceny_user1";
  21. $queries[] = "SELECT WOS FROM oceny_user1";
  22. $queries[] = "SELECT Specjalizacja1 FROM oceny_user1";
  23. $queries[] = "SELECT Specjalizacja2 FROM oceny_user1";
  24. $queries[] = "SELECT Specjalizacja3 FROM oceny_user1";
  25.  
  26. for($i=0; $i<count($queries); $i++){
  27. $result[$i] = mysql_query($queries[$i], $connection)
  28. or die("Nie mogę wykonać zapytania dla tablicy ".$i);
  29. }
  30.  
  31. ?>
  32.  
  33. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  34. "http://www.w3.org/TR/html4/loose.dtd">
  35. <html>
  36. <head>
  37. <title>TwojeOceny&reg;</title>
  38. <meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
  39. <style type="text/css">
  40.  
  41. <!--- STYLE(skróciłem) --->
  42.  
  43. </style>
  44. </head>
  45. <body>
  46. <center><h3>Oceny dla: user1</h3></center>
  47. <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" align="center">
  48. <tr>
  49. <td>
  50. <table onMouseOver="this.className='tablecursor'" border="1" style="border-collapse: collapse" bordercolor="#000000" align="center" bgcolor="#FFFFFF">
  51. <tr><td onMouseOver="this.className='overstyle'" onMouseOut="this.className='normalstyle'">Biologia</td></tr>
  52. <tr><td onMouseOver="this.className='overstyle'" onMouseOut="this.className='normalstyle'">Chemia</td></tr>
  53. <tr><td onMouseOver="this.className='overstyle'" onMouseOut="this.className='normalstyle'">Fizyka</td></tr>
  54. <tr><td onMouseOver="this.className='overstyle'" onMouseOut="this.className='normalstyle'">Geografia</td></tr>
  55. <tr><td onMouseOver="this.className='overstyle'" onMouseOut="this.className='normalstyle'">Historia</td></tr>
  56. <tr><td onMouseOver="this.className='overstyle'" onMouseOut="this.className='normalstyle'">J. Angielski</td></tr>
  57. <tr><td onMouseOver="this.className='overstyle'" onMouseOut="this.className='normalstyle'">J. Niemiecki</td></tr>
  58. <tr><td onMouseOver="this.className='overstyle'" onMouseOut="this.className='normalstyle'">J. Polski</td></tr>
  59. <tr><td onMouseOver="this.className='overstyle'" onMouseOut="this.className='normalstyle'">Matematyka</td></tr>
  60. <tr><td onMouseOver="this.className='overstyle'" onMouseOut="this.className='normalstyle'">Religia</td></tr>
  61. <tr><td onMouseOver="this.className='overstyle'" onMouseOut="this.className='normalstyle'">WF</td></tr>
  62. <tr><td onMouseOver="this.className='overstyle'" onMouseOut="this.className='normalstyle'">WOS</td></tr>
  63. <tr><td onMouseOver="this.className='overstyle'" onMouseOut="this.className='normalstyle'">Specjalizacja1</td></tr>
  64. <tr><td onMouseOver="this.className='overstyle'" onMouseOut="this.className='normalstyle'">Specjalizacja2</td></tr>
  65. <tr><td onMouseOver="this.className='overstyle'" onMouseOut="this.className='normalstyle'">Specjalizacja3</td></tr>
  66. </table>
  67. </td>
  68. <td>
  69.  
  70. <table onMouseOver="this.className='tablecursor'" border="1" style="border-collapse: collapse" bordercolor="#000000" align="center" bgcolor="#FFFFFF">
  71.  
  72. <?php
  73.  
  74. echo "<tr onMouseOver=\"this.className='overstyle'\" onMouseOut=\"this.className='normalstyle'\">";
  75. while($row00 = mysql_fetch_row($result[0])){
  76. echo '<td>'.$row00[0].'</td>';
  77. }
  78. echo '</tr>';
  79. echo "<tr onMouseOver=\"this.className='overstyle'\" onMouseOut=\"this.className='normalstyle'\">";
  80. while($row01 = mysql_fetch_row($result[1])){
  81. echo '<td>'.$row01[0].'</td>';
  82. }
  83. echo '</tr>';
  84. echo "<tr onMouseOver=\"this.className='overstyle'\" onMouseOut=\"this.className='normalstyle'\">";
  85. while($row02 = mysql_fetch_row($result[2])){
  86. echo '<td>'.$row02[0].'</td>';
  87. }
  88. echo '</tr>';
  89. echo "<tr onMouseOver=\"this.className='overstyle'\" onMouseOut=\"this.className='normalstyle'\">";
  90. while($row03 = mysql_fetch_row($result[3])){
  91. echo '<td>'.$row03[0].'</td>';
  92. }
  93. echo '</tr>';
  94. echo "<tr onMouseOver=\"this.className='overstyle'\" onMouseOut=\"this.className='normalstyle'\">";
  95. while($row04 = mysql_fetch_row($result[4])){
  96. echo '<td>'.$row04[0].'</td>';
  97. }
  98. echo '</tr>';
  99. echo "<tr onMouseOver=\"this.className='overstyle'\" onMouseOut=\"this.className='normalstyle'\">";
  100. while($row05 = mysql_fetch_row($result[5])){
  101. echo '<td>'.$row05[0].'</td>';
  102. }
  103. echo '</tr>';
  104. echo "<tr onMouseOver=\"this.className='overstyle'\" onMouseOut=\"this.className='normalstyle'\">";
  105. while($row06 = mysql_fetch_row($result[6])){
  106. echo '<td>'.$row06[0].'</td>';
  107. }
  108. echo '</tr>';
  109. echo "<tr onMouseOver=\"this.className='overstyle'\" onMouseOut=\"this.className='normalstyle'\">";
  110. while($row07 = mysql_fetch_row($result[7])){
  111. echo '<td>'.$row07[0].'</td>';
  112. }
  113. echo '</tr>';
  114. echo "<tr onMouseOver=\"this.className='overstyle'\" onMouseOut=\"this.className='normalstyle'\">";
  115. while($row08 = mysql_fetch_row($result[8])){
  116. echo '<td>'.$row08[0].'</td>';
  117. }
  118. echo '</tr>';
  119. echo "<tr onMouseOver=\"this.className='overstyle'\" onMouseOut=\"this.className='normalstyle'\">";
  120. while($row09 = mysql_fetch_row($result[9])){
  121. echo '<td>'.$row09[0].'</td>';
  122. }
  123. echo '</tr>';
  124. echo "<tr onMouseOver=\"this.className='overstyle'\" onMouseOut=\"this.className='normalstyle'\">";
  125. while($row10 = mysql_fetch_row($result[10])){
  126. echo '<td>'.$row10[0].'</td>';
  127. }
  128. echo '</tr>';
  129. echo "<tr onMouseOver=\"this.className='overstyle'\" onMouseOut=\"this.className='normalstyle'\">";
  130. while($row11 = mysql_fetch_row($result[11])){
  131. echo '<td>'.$row11[0].'</td>';
  132. }
  133. echo '</tr>';
  134. echo "<tr onMouseOver=\"this.className='overstyle'\" onMouseOut=\"this.className='normalstyle'\">";
  135. while($row12 = mysql_fetch_row($result[12])){
  136. echo '<td>'.$row12[0].'</td>';
  137. }
  138. echo '</tr>';
  139. echo "<tr onMouseOver=\"this.className='overstyle'\" onMouseOut=\"this.className='normalstyle'\">";
  140. while($row13 = mysql_fetch_row($result[13])){
  141. echo '<td>'.$row13[0].'</td>';
  142. }
  143. echo '</tr>';
  144. echo "<tr onMouseOver=\"this.className='overstyle'\" onMouseOut=\"this.className='normalstyle'\">";
  145. while($row14 = mysql_fetch_row($result[14])){
  146. echo '<td>'.$row14[0].'</td>';
  147. }
  148. echo '</tr>';
  149.  
  150. ?>
  151.  
  152. </table>
  153. </td>
  154. <td>
  155. <table onMouseOver="this.className='tablecursor'" border="1" style="border-collapse: collapse" bordercolor="#000000" align="center" bgcolor="#FFFFFF">
  156. <tr><td onMouseOver="this.className='overstyle'" onMouseOut="this.className='normalstyle'">
  157. +
  158. </td></tr>
  159. <tr><td onMouseOver="this.className='overstyle'" onMouseOut="this.className='normalstyle'">
  160. +
  161. </td></tr>
  162. <tr><td onMouseOver="this.className='overstyle'" onMouseOut="this.className='normalstyle'">
  163. +
  164. </td></tr>
  165. <tr><td onMouseOver="this.className='overstyle'" onMouseOut="this.className='normalstyle'">
  166. +
  167. </td></tr>
  168. <tr><td onMouseOver="this.className='overstyle'" onMouseOut="this.className='normalstyle'">
  169. +
  170. </td></tr>
  171. <tr><td onMouseOver="this.className='overstyle'" onMouseOut="this.className='normalstyle'">
  172. +
  173. </td></tr>
  174. <tr><td onMouseOver="this.className='overstyle'" onMouseOut="this.className='normalstyle'">
  175. +
  176. </td></tr>
  177. <tr><td onMouseOver="this.className='overstyle'" onMouseOut="this.className='normalstyle'">
  178. +
  179. </td></tr>
  180. <tr><td onMouseOver="this.className='overstyle'" onMouseOut="this.className='normalstyle'">
  181. +
  182. </td></tr>
  183. <tr><td onMouseOver="this.className='overstyle'" onMouseOut="this.className='normalstyle'">
  184. +
  185. </td></tr>
  186. <tr><td onMouseOver="this.className='overstyle'" onMouseOut="this.className='normalstyle'">
  187. +
  188. </td></tr>
  189. <tr><td onMouseOver="this.className='overstyle'" onMouseOut="this.className='normalstyle'">
  190. +
  191. </td></tr>
  192. <tr><td onMouseOver="this.className='overstyle'" onMouseOut="this.className='normalstyle'">
  193. +
  194. </td></tr>
  195. <tr><td onMouseOver="this.className='overstyle'" onMouseOut="this.className='normalstyle'">
  196. +
  197. </td></tr>
  198. <tr><td onMouseOver="this.className='overstyle'" onMouseOut="this.className='normalstyle'">
  199. +
  200. </td></tr>
  201. </table>
  202. </td>
  203. </table>
  204. </body>
  205. </html>
  206.  
  207.  
  208. <?php
  209.  
  210.  
  211. ?>


a Tak to wygląda w przeglądarce:
(IMG:http://oceny.slowak.kom.pl/img/ie.jpg)

Bardzo proszę o pomoc,
pzdr,
PaKoS

Ten post edytował PaKoS 25.03.2006, 18:06:11
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 6.10.2025 - 06:57