Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [MySQL][PHP]Drugi SELECT w foreach
przemokrosno
post
Post #1





Grupa: Zarejestrowani
Postów: 21
Pomógł: 0
Dołączył: 30.09.2008
Skąd: Krosno

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


Witam
Napisałem skrypt który działa ale tylko do SELECT w instrukcji foreach (kod który się nie wykonuje zaznaczyłem /*):
  1. <?php
  2. include '../includes/common.inc.php';
  3. include '../includes/klasy.inc.php';
  4. include '../includes/students.inc.php';
  5. include '../includes/oceny.inc.php';
  6.  
  7. require_group(_TEACHER_GROUP);
  8. page_header();
  9. page_menu();
  10.  
  11. if (isset($_GET['success'])) { if ($_GET['success'] == 1) { $success = 'Oceny zapisano pomyślnie.'; } }
  12. ?>
  13.  
  14. <div id="content">
  15. <h2>Oceny</h2>
  16. <div id="breadcrumb"><a href="<?=$conf_settings['site_url']?>">Strona główna</a> -> <em>Oceny</em></div>
  17.  
  18. <?php if ($success) echo "<strong class=\"success\">$success</strong>"; ?>
  19.  
  20. <div style="clear: both;"></div>
  21.  
  22. <p>Witaj w systemie ocen. Tutaj możesz dodawać oceny, przeglądać i edytować oceny. Wybirz klasę i przedmiot w której zamierzasz wykonać te operacje.</p>
  23.  
  24. <?php
  25. if (authUserInGroup($_SESSION['username'], _TEACHER_GROUP)) { $classlist = classGetClassesByCreator($_SESSION['username']); // get array of classes since the beginning of time
  26. } elseif (authUserInGroup($_SESSION['username'], _ADMIN_GROUP)) { $classlist = classGetClassesAfterTime(0); }
  27.  
  28. if (empty($classlist)) { // no classes
  29. ?>
  30. W tej chwili nie ma dostępnych klas. Kliknij tutaj aby <a href="/klasy/new.php">utworzyć nową klasę</a>.
  31. <?php
  32. } else {
  33. ?>
  34. <div style="float: left;">
  35. <p>Wybierz przedmiot:</p>
  36. <p>
  37. <?php
  38. if (!empty($classlist)) {
  39. ?>
  40. <table cellpadding=5 class="classlist">
  41. <tr><th>Nazwa</th><th>Przedmioty Klasy</th></tr>
  42. <?php
  43. $i = 0;
  44. foreach ($classlist as $class)
  45. {
  46. $i++;
  47. if ($i % 2)
  48. echo '<tr class="even">';
  49. else
  50. echo '<tr class="odd">';
  51. echo '<td rowspan="15">' . $class['name'] . '</a></td>';
  52.  
  53. /*
  54.   $przedmiotlist = "SELECT * FROM `intra_classlesson` WHERE `classid` = '" .$classid. "' ";
  55.   if ($numToGet) { $przedmiotlist.='LIMIT $start, $numToGet'; }
  56.   $result=mysql_query($przedmiotlist) or die(mysql_error());
  57.   $return=array();
  58.   while ($row=mysql_fetch_assoc($result)) { $return[]=$row; } return $return;
  59.  
  60.  if (!empty($przedmiotlist)) {
  61.  echo "<pre>".print_r($przedmiotlist, true)."</pre>";
  62. $i = 0;
  63. foreach ($przedmiotlist as $przedmiot)
  64. {
  65. $i++;
  66.  
  67. $przedmiotinfo = ' SELECT lessonname FROM intra_lesson WHERE id="' .$przedmiot['przedmiotid'].'" ';
  68.   $result=mysql_query($przedmiotinfo) or die(mysql_error());
  69.   return mysql_fetch_assoc($result);
  70.  
  71. if ($i % 2) echo '<tr class="even">'; else echo '<tr class="odd">';
  72. echo '<td><a href="/oceny/do.php?classid='.$id.'&przedmiotid=' . $przedmiot['przedmiotid'] . '">'.$przedmiotinfo['lessonname'].'</a></td>';
  73. echo '</tr>';
  74. echo "\n";
  75. }
  76.  } else {
  77. ?><td>
  78. W tej chwili nie ma przedmiotów w tej klasie. Tutaj możesz <a href="addprzedmiot.php">dodać przedmiot do tej klasy</a>.</td>
  79. <?php
  80.  }
  81.  
  82. */
  83. echo '</tr>';
  84. echo "\n";
  85. }
  86. echo '</table>';
  87. }else {
  88. ?><td colspan="2">
  89. W tej chwili nie ma klas w bazie danych. Tutaj możesz <a href="newclass.php">utworzyć nową klasę</a>.</td>
  90. <?php
  91. }
  92. ?>
  93. </p>
  94. <div style="clear: both;"></div>
  95. <?php
  96. }
  97. ?>
  98. </div> <!-- content -->
  99. <?php
  100. page_footer();
  101. ?>


Co zrobiłem nie tak i dlaczego ten fragment kodu nie może sie wykonać? Bardzo proszę o pomoc.
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 20.08.2025 - 10:01