Dobra
EDIT : Zrobiłem coś takiego wszystko działa, tylko gdzieś w drugiej tabeli w poleceniu INSERT INTO jest chyba błąd (nie moge sprawdzić w SQL bo nie mam tam zmiennych ). Chciałem użyć do tego tablicy asc. ale też nie daje efektów :/
<?php
if ($_SESSION['nauczyciel'] == false)
{
header('Location: logout.php'); }
echo "<p>Witaj ".$_SESSION['user'].'! [ <a href="logout.php">Wyloguj się!</a> ] </p>';
require_once "connect.php";
$polaczenie = mysqli_connect($db_host, $db_user, $db_password, $db_name);
mysqli_query($polaczenie, "SET CHARSET utf8");
mysqli_query($polaczenie, "SET NAMES 'utf8' COLLATE 'utf8_polish_ci'");
mysqli_select_db($polaczenie, $database);
$class = $_SESSION['class'] ;
$rezultat = mysqli_query($polaczenie, ("SELECT uczniowie.id, uczniowie.klasa, uczniowie.nr, oceny.id_ucznia, oceny.polski, oceny.matematyka, oceny.niemiecki, oceny.angielski, oceny.wf, oceny.informatyka, oceny.fizyka, oceny.biologia, oceny.fizyka, oceny.biologia, oceny.historia, oceny.religia, oceny.technika, oceny.chemia, oceny.geografia FROM oceny, uczniowie WHERE uczniowie.id = oceny.id_ucznia AND uczniowie.klasa = '$class' ORDER BY uczniowie.nr ASC"));
$ile = mysqli_num_rows($rezultat);
$_SESSION['ile'] = $ile;
if ($ile>=1)
{
<td width="50" align="center" bgcolor="e5e5e5">Nr</td>
<td width="100" align="center" bgcolor="e5e5e5">Polski</td>
<td width="100" align="center" bgcolor="e5e5e5">Matematyka</td>
<td width="100" align="center" bgcolor="e5e5e5">Angielski</td>
<td width="100" align="center" bgcolor="e5e5e5">Niemiecki</td>
<td width="100" align="center" bgcolor="e5e5e5">WF</td>
<td width="100" align="center" bgcolor="e5e5e5">Informatyka</td>
<td width="100" align="center" bgcolor="e5e5e5">Fizyka</td>
<td width="100" align="center" bgcolor="e5e5e5">Biologia</td>
<td width="100" align="center" bgcolor="e5e5e5">Historia</td>
<td width="100" align="center" bgcolor="e5e5e5">Religia</td>
<td width="100" align="center" bgcolor="e5e5e5">Technika</td>
<td width="100" align="center" bgcolor="e5e5e5">Chemia</td>
<td width="100" align="center" bgcolor="e5e5e5">Geografia</td>
</tr><tr >
END;
}
for ($i = 1; $i <= $ile; $i++)
{
$row = mysqli_fetch_assoc($rezultat);
$a1 = $row['nr'];
$a2 = $row['polski'];
$a3 = $row['matematyka'];
$a4 = $row['angielski'];
$a5 = $row['niemiecki'];
$a6 = $row['wf'];
$a7 = $row['informatyka'];
$a8 = $row['fizyka'];
$a9 = $row['biologia'];
$a10 = $row['historia'];
$a11 = $row['religia'];
$a12 = $row['technika'];
$a13 = $row['chemia'];
$a14 = $row['geografia'];
<td width="50" align="center">$a1</td>
<td width="100" align="center">$a2</td>
<td width="100" align="center">$a3</td>
<td width="100" align="center">$a4</td>
<td width="100" align="center">$a5</td>
<td width="100" align="center">$a6</td>
<td width="100" align="center">$a7</td>
<td width="100" align="center">$a8</td>
<td width="100" align="center">$a9</td>
<td width="100" align="center">$a10</td>
<td width="100" align="center">$a11</td>
<td width="100" align="center">$a12</td>
<td width="100" align="center">$a13</td>
<td width="100" align="center">$a14</td>
</tr><tr>
END;
}
echo '<table width="100%" align="center" border="1" bordercolor="#d5d5d5" cellpadding="0" cellspacing="0"><tr>';
$i = 1;
echo '<form action="klasa.php" method="post" name="edit"> <input type="submit" value="Submit" ></form>' ; if ($ile>=1)
{
<td width="50" align="center" bgcolor="e5e5e5">Nr</td>
<td width="100" align="center" bgcolor="e5e5e5">Polski</td>
<td width="100" align="center" bgcolor="e5e5e5">Matematyka</td>
<td width="100" align="center" bgcolor="e5e5e5">Angielski</td>
<td width="100" align="center" bgcolor="e5e5e5">Niemiecki</td>
<td width="100" align="center" bgcolor="e5e5e5">WF</td>
<td width="100" align="center" bgcolor="e5e5e5">Informatyka</td>
<td width="100" align="center" bgcolor="e5e5e5">Fizyka</td>
<td width="100" align="center" bgcolor="e5e5e5">Biologia</td>
<td width="100" align="center" bgcolor="e5e5e5">Historia</td>
<td width="100" align="center" bgcolor="e5e5e5">Religia</td>
<td width="100" align="center" bgcolor="e5e5e5">Technika</td>
<td width="100" align="center" bgcolor="e5e5e5">Chemia</td>
<td width="100" align="center" bgcolor="e5e5e5">Geografia</td>
</tr><tr >
END;
}
for ($i = 1; $i <= $ile; $i++)
{
<td width="10" align="center"><input type="hidden" name="$b1" value="$i"></td>
<td width="100" align="center"><input type="text" name="$b2" ></td>
<td width="100" align="center"><input type="text" name="$b3" ></td>
<td width="100" align="center"><input type="text" name="$b4" ></td>
<td width="100" align="center"><input type="text" name="$b5" ></td>
<td width="100" align="center"><input type="text" name="$b6" ></td>
<td width="100" align="center"><input type="text" name="$b7" ></td>
<td width="100" align="center"><input type="text" name="$b8" ></td>
<td width="100" align="center"><input type="text" name="$b9" ></td>
<td width="100" align="center"><input type="text" name="$b10" ></td>
<td width="100" align="center"><input type="text" name="$b11" ></td>
<td width="100" align="center"><input type="text" name="$b12" ></td>
<td width="100" align="center"><input type="text" name="$b13" ></td>
<td width="100" align="center"><input type="text" name="$b14" ></td>
</tr><tr></form>
END;
if(isset($_POST['submit'])) { $b1 = $_POST['b1'];
$b2 = $_POST['b2'];
$b3 = $_POST['b3'];
$b4 = $_POST['b4'];
$b5 = $_POST['b5'];
$b6 = $_POST['b6'];
$b7 = $_POST['b7'];
$b8 = $_POST['b8'];
$b9 = $_POST['b9'];
$b10 = $_POST['b10'];
$b11 = $_POST['b11'];
$b12 = $_POST['b12'];
$b13 = $_POST['b13'];
$b14 = $_POST['b14'];
$oceny = array("id_ucznia" => $i, "polski" => $b2,"matematyka" => $b3, "angielski" => $b4, "niemiecki" => $b5, "wf" => $b6, "informatyka" => $b7, "fizyka" => $b8, "biologia" => $b9, "historia" => $b10, "religia" => $b11, "technika" => $b12, "chemia" => $b13, "geografia" => $b14,);
$oceny['id_ucznia'] = $b1;
$oceny['polski'] = $b2;
$oceny['matematyka'] = $b3;
$oceny['angielski'] = $b4;
$oceny['niemiecki'] = $b5;
$oceny['wf'] = $b6;
$oceny['informatyka'] = $b7;
$oceny['fizyka'] = $b8;
$oceny['biologia'] = $b9;
$oceny['historia'] = $b10;
$oceny['religia'] = $b11;
$oceny['technika'] = $b12;
$oceny['chemia'] = $b13;
$oceny['geografia'] = $b14;
$edit = mysqli_query($link, ("INSTERT INTO oceny ( polski, matematyka, angielski, niemiecki, wf, informatyka, fizyka, biologia, historia, religia, technika, chemia, geografia) VALUES ('$b2', '$b3', '$b4', '$b5', '$b6', '$b7', '$b8', '$b9', '$b10', '$b11', '$b12', '$b13', '$b14') WHERE id_ucznia LIKE".$i));
mysqli_free_result($edit);
}
/* close connection */
mysqli_close($link);
}
?>
EDIT błędy znikneły ale dalej nie działa ...
<td width="10" align="center"><input type="hidden" name="b1" value="$i"></td>
<td width="100" align="center"><input type="text" name="b2" ></td>
<td width="100" align="center"><input type="text" name="b3" ></td>
<td width="100" align="center"><input type="text" name="b4" ></td>
<td width="100" align="center"><input type="text" name="b5" ></td>
<td width="100" align="center"><input type="text" name="b6" ></td>
<td width="100" align="center"><input type="text" name="b7" ></td>
<td width="100" align="center"><input type="text" name="b8" ></td>
<td width="100" align="center"><input type="text" name="b9" ></td>
<td width="100" align="center"><input type="text" name="b10" ></td>
<td width="100" align="center"><input type="text" name="b11" ></td>
<td width="100" align="center"><input type="text" name="b12" ></td>
<td width="100" align="center"><input type="text" name="b13" ></td>
<td width="100" align="center"><input type="text" name="b14" ></td>
</tr><tr></form>
if(isset($_POST['submit'])) { $b1 = $_POST['b1'];
$b2 = $_POST['b2'];
$b3 = $_POST['b3'];
$b4 = $_POST['b4'];
$b5 = $_POST['b5'];
$b6 = $_POST['b6'];
$b7 = $_POST['b7'];
$b8 = $_POST['b8'];
$b9 = $_POST['b9'];
$b10 = $_POST['b10'];
$b11 = $_POST['b11'];
$b12 = $_POST['b12'];
$b13 = $_POST['b13'];
$b14 = $_POST['b14'];
Kod
Static analysis:
4 errors were found during analysis.
Unexpected character. (near "$" at position 154)
Unexpected character. (near "$" at position 270)
Unexpected beginning of statement. (near "INSTERT" at position 0)
Unrecognized statement type. (near "INTO" at position 8)
Zapytanie SQL:
INSTERT INTO oceny ( polski, matematyka, angielski, niemiecki, wf, informatyka, fizyka, biologia, historia, religia, technika, chemia, geografia) VALUES ($b2, '$b3', '$b4', '$b5', '$b6', '$b7', '$b8', '$b9', '$b10', '$b11', '$b12', '$b13', '$b14') WHERE id_ucznia LIKE.$i
MySQL zwrócił komunikat: Dokumentacja
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'INSTERT INTO oceny ( polski, matematyka, angielski, niemiecki, wf, informatyka, ' at line 1
Ten post edytował damiandamian 8.12.2016, 20:29:47