Poniżej znajduje się cały kod umieszczam go, ponieważ jak daje isset w:
else if ($_GET["wybor"] == 'DEL')
to wtedy jak kliknę "Szukaj imie" z moja stroną dzieją się takie rzeczy
Notice: Undefined index: id in G:\wamp\www\formularz.php on line 72
blad
BŁĄD:Query was empty
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1250" />
<title>Projekt bazy danych</title>
<link rel="stylesheet" type="text/css" href="styl.css" />
</head>
<body>
<div id="h2">
<form action="formularz.php" method="post">
<p align="right">
<input type ="hidden" name="wybor" value="dodaj">
<table>
id klienta:<input type ="text" name="id"><br />
imie:<input type ="text" name="imie"><br />
nazwisko:<input type ="text" name="nazwisko"><br />
nazwa firmy:<input type ="text" name="nazwa_firmy"><br />
telefon:<input type ="text" name="telefon"><br />
<input type ="submit" value="dodaj">
</table>
</p>
</form>
</div>
<?php
mysql_connect("localhost", "szymon", "28360405") or
die ("Nie można połączyć się z bazą"); echo '<form action= "formularz.php" method="get">'; echo '<input type ="hidden" name="wybor" value="szukaj">'; echo '<input type= "text" name="napis">'; echo '<input type= "submit" value="Szukaj imie">';
echo '<form action= "formularz.php" method="get">'; echo '<input type ="hidden" name="wybor" value="DEL">'; echo '<input type ="hidden" name="wybor" value="edit">'; echo '<input type= "hidden" name="id">';
echo '<form action= "formularz.php" method="get">'; echo '<input type ="hidden" name="wybor" value="edit">'; echo '<input type= "hidden" name="id">';
if(isset($_POST["wybor"])== 'dodaj') {
$imie1=$_POST['imie'];
$nazwisko1=$_POST['nazwisko'];
$nazwa1=$_POST['nazwa_firmy'];
$telefon1=$_POST['telefon'];
if($imie1 and $nazwisko1 and $nazwa1 and $telefon1)
{
$ins =mysql_query("insert into klienci set imie='$imie1', nazwisko='$nazwisko1', nazwa_firmy='$nazwa1',telefon='$telefon1'"); if($ins) echo "Rekord został dodany poprawnie"; else echo "Błąd nie udało się dodać nowego rekordu"; }
}
else if (isset($_GET["wybor"]) == 'DEL') {
$zapytanie3="DELETE from Klienci where id_klienta=$_GET[id];";
if($del)
{
echo '<h5>rekord usuniety</h5>';
}
else
{
}
}
else if ($_GET["wybor"] == 'edit')
{
echo '<form action="formularz.php" method="post">'; echo '<p align="right">'; echo 'id klienta:<input type ="text" name="id"><br />'; echo 'imie:<input type ="text" name="imie"><br />'; echo 'nazwisko:<input type ="text" name="nazwisko"><br />'; echo 'nazwa firmy:<input type ="text" name="nazwa_firmy"><br />'; echo 'telefon:<input type ="text" name="telefon"><br />'; echo '<input type ="submit" value="zmień">'; }
else if (isset($_GET["napis"])) {
$zapytanie2="SELECT *from klienci where imie='$_GET[napis]'";
if ($_GET["wybor"]== 'szukaj')
{
{
echo ("<h1><b>Znaleziono</b></h1>"); //echo '<div id="h6">';
echo "<table cellpading=5 border=2>"; echo "<td><b>Id_klienta</td></b>"; echo "<td><b>Imie</td></b>"; echo "<td><b>Nazwisko</td></b>"; echo "<td><b>Nazwa firmy</td></b>"; echo "<td><b>Telefon</td></b>"; }
else echo ("<h1><b>Nie ma</b></h1>");
{
$id2 =$rek[0];
$imie2=$rek[1];
$nazwisko2=$rek[2];
$nazwa_firmy2=$rek[3];
$telefon2=$rek[4];
echo "<td><b>$id2</td></b>"; echo "<td><b>$imie2</td></b>"; echo "<td><b>$nazwisko2</td></b>"; echo "<td><b>$nazwa_firmy2</td></b>"; echo "<td><b>$telefon2</td></b>"; //echo '</div>';
}
echo '<a href ="formularz.php"> Powrot do formularza</a>';
}
}
$zapytanie1 = "SELECT *from klienci";
//echo '<div id="h4">';
echo "<table cellpading=5 border=2>"; echo "<td><b>Id_klienta</td></b>"; echo "<td><b>Imie</td></b>"; echo "<td><b>Nazwisko</td></b>"; echo "<td><b>Nazwa firmy</td></b>"; echo "<td><b>Telefon</td></b>";
{
$id =$rekord[0];
$imie=$rekord[1];
$nazwisko=$rekord[2];
$nazwa_firmy=$rekord[3];
$telefon=$rekord[4];
echo "<td><b>$id</td></b>"; echo "<td><b>$imie</td></b>"; echo "<td><b>$nazwisko</td></b>"; echo "<td><b>$nazwa_firmy</td></b>"; echo "<td><b>$telefon</td></b>"; echo "<td><a href = \"formularz.php?wybor=DEL&Id=$id\">kasuj</a></td>"; echo "<td><a href = \"formularz.php?wybor=edit&Id=$id\">edytuj</a></td>"; }
//echo '</div>';
?>
</body>
</html>