oto kod:
<html>
<head>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1250\">
<title>studenci</title>
</head>
<body>
<?php
@ $polaczenie = mysql_pconnect('localhost','root',''); //laczenie sie z serwerem , wybiera nazwe hosta,login i haslo if (!@polaczenie)
{
echo 'Nieudało sie polączenie z baza!'; //wyswietla komunikat o bledzie gdy niepowiedzie sie polaczenie z serwerem }
if ($operacja == 'zmien') //warunek jesli jest spelniony zaczyna sie edycja danych studenta
{
if ($nr_indexu && $imie && $nazwisko && $haslo)
{
$zapytanie = \"update uczen set nr_indexu='$nr_indexu', imie='$imie', nazwisko='$nazwisko', haslo='$haslo' where nr_indexu = '$nr'\";
}
elseif ($operacja == 'edycja')
{
$zapytanie = \"select * from uczen where nr_indexu = '$nr';\";
$nr_indexu = $pozycja[0];
$imie = $pozycja[1];
$nazwisko = $pozycja[2];
$haslo = $pozycja[3];
print '<form method=\"post\">Napraw pozycje:'; print '<input type=\"hidden\" name=\"operacja\" value=\"zmien\">'; print '<input type=\"hidden\" name=\"nr\" value\"'.$nr.'\"><table>'; print '<tr><td>Nr indexu</td><td><input type=\"text\" '; print 'name=\"nr_indexu\" value=\"'.$nr_indexu.'\"></td></tr><tr><td>Imie'; print '</td><td><input type=\"text\" name=\"imie\"'; print 'value=\"'.$imie.'\"></td></tr><tr><td>Nazwisko'; print '</td><td><input type=\"text\"'; print 'name=\"nazwisko\" value=\"'.$nazwisko.'\"></td></tr><tr><td>Haslo'; print '</td><td><input type=\"text\" name=\"haslo\"'; print 'value=\"'.$haslo.'\"></td></tr>'; print '</table><input type=\"submit\" value=\"zmien\"></form>'; }
elseif ($operacja == 'usun') //warunek jesli jest spelniony kasuje studenta o wybranym numerze indexu
{
$wynik_zapytania = mysql_query (\"delete from uczen where nr_indexu = '$nr';\"); }
$wynik_zapytania = mysql_query (\"select * from uczen;\") or die (\"złe zapytanie\"); print \"<table cellpading=2 border=1>\"; print \"<tr><td>Numer Indexu</td><td>Imię</td><td>Nazwisko</td><td>Hasło</td></tr>\"; {
$nr_indexu = $pozycja[0];
$imie = $pozycja[1];
$nazwisko = $pozycja[2];
$haslo = $pozycja[3];
print \"<tr><td>$nr_indexu</td><td>$imie</td><td>$nazwisko</td><td>$haslo</td><td>\"; print \"<A HREF=\"s.php?operacja=usun&nr=$nr_indexu\">usun</A></td><td>\"; print \"<A HREF=\"s.php?operacja=edycja&nr=$nr_indexu\">edycja</A></td></tr>n\"; }
?>
</body>
Ten post edytował seaquest 20.12.2004, 17:32:53