Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [php] usuwanie danych
Forum PHP.pl > Forum > Przedszkole
kosmic
no i tak co chwile schody, ale staram sie i walcze.....

a wiec dodawanie kategori do mojej galerii działa już poprawnie, ale teraz chce zrobic usuniecie i edycje no nie bardzo mi dziala i nie wiem dlaczego....

najpierw usun, a analogicznie zrobie edycje...
wiec to moj plik kategor.php
Kod
<?php
session_start();
$s_id = session_id();
require('my_db_connect.php');
require('wer_pass.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<link rel="Stylesheet" href="style.css" type="text/css">
<meta http-equiv="Content-type" content="text/html; charset=iso-8859-2" />
<title></title>
</head>
<body>
<table border="0" cellpadding="5" cellspacing="0" width="100%" height="20">
<tr>
    <td valign="top" class="admin"><b>Administracja/galria zdjec/zarzadzanie kategoriami</b></td>
</tr>
</table>

<table border="0" cellpadding="5" cellspacing="0" width="100%" height="20">
<tr>
    <td valign="top" width="200"><? include("menu.php"); ?></td>
    <td>
        <table border="0" cellpadding="5" cellspacing="2" width="100%" height="20">
        <tr>
            <td class="tytul_adm_cen"><b>Dodawanie nowej kategorii</b></td>
        </tr>
        </table>
        
        <table border="0" cellpadding="5" cellspacing="2" width="100%" height="20">
        <tr>
            <td valign="top" class="adm_cen">
            
            <table border="0" cellpadding="5" cellspacing="0" width="100%" height="20" bgcolor="#000000">
                <tr>
                    <td class="adm_cen_tresc" height="10"></td>
                </tr>
                <tr>
                    <td valign="top" class="adm_cen_tresc">
                <form action="dodaj_kat.php" method="post" enctype="multipart/form-data">
                
                <b>Kategoria</b><br>
                <input type="text" name="kat_form" size="40" maxlength="50"/><br/>
                <input  type="hidden" name="PHPSESSID" value="<? echo $s_id;?>"><br/>
                
                <b>Opis kategorii<b><br>
                <textarea name="opis_kat_form" value="" rows="5" cols="50"></textarea><br><br/>
                <input type="submit" value="Dodaj kategorie"><br><br/>
                </form>
                    </td>
                </tr>
            </table>
            </td>
        </tr>
        </table>
        
        <table border="0" cellpadding="5" cellspacing="2" width="100%" height="20">
        <tr>
            <td>&nbsp;</td>
        </tr>
        </table>
        
        <table border="0" cellpadding="5" cellspacing="2" width="100%" height="20">
        <tr>
            <td class="tytul_adm_cen"><b>Usuwanie kategorii</b></td>
        </tr>
        </table>
        
        <table border="0" cellpadding="5" cellspacing="2" width="100%" height="20">
        <tr>
            <td valign="top" class="adm_cen">
            
            <table border="0" cellpadding="5" cellspacing="0" width="100%" height="20" bgcolor="#000000">
                <tr>
                    <td class="adm_cen_tresc" height="10"></td>
                </tr>
                <tr>
                    <td valign="top" class="adm_cen_tresc">
                    <b>Kategorie znajdujace sie w bazie</b><br>
<?
$zap_kat = mysql_query ("SELECT  *  FROM  kategoria  ORDER BY pozycja ASC");

echo '<table cellpadding="0" cellspacing="0" border="0" width="200">';
echo '<tr>';
echo '<td colspan="2" height="10"></td>';
echo '</tr>';
while($wynik = mysql_fetch_array($zap_kat)) {
    echo '<tr>';
    echo '<td height="20" align=left width="120">'.$wynik['kategoria'].'</td>';
    echo '<td height="20" align="right" width="80">- [ <a href=kategor.php?usun&kat='.$wynik['id'].'&PHPSESSID='.$s_id.' class=\"menu_link\">usuń</a> ]</td>';
    echo '</tr>';
    }
echo '</table>';

if(isset($_GET['kategoria']) && $_GET['kategoria']=='usun' && isset($_GET['id']))
    {
    $id=$_GET['id'];
    mysql_query("DELETE FROM kategoria WHERE id='$id'");
    $message .= 'Pomyślnie usunołes kategorie numer '.$id.'!';
    }
?>
                    </td>
                </tr>
            </table>
            </td>
        </tr>
        </table>
<br>
        <div align="left">
        <?php
        if(isset($message)) {
            echo $message;
            }
        ?>
        </div>
    </td>
</tr>
</table>
</body>
</html>


no i jak zauwazycie jest przycisk usun, ktory ma usunac kategorie, ale nie stety nie działa, to znaczy nic sie nie dzieje sad.gif

ktos pomoze questionmark.gif
kossa
w linku do usuwania nie masz zmiennej kategoria a w instrukcji if takiej oczekujesz

Łukasz
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.