Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Problem with delete function...
Old 05-14-2010, 04:31 PM Problem with delete function...
Experienced Talker

Posts: 32
Name: Kleidi
Trades: 0
Hello everyone!

I have a script that when i click on a category is opened a new page (katlajme_edit.php on my case) where are loaded all infos of that category on a form and at the end of that form is a checkbox that offers the delete option for that category...but...it didn;t work! I don't know what's going on, bcz didn;t appear any error msg. It says that the modifications is done but that row is not deleted !

This is my script:
PHP Code:
 <? 
include('header.php'); 

echo 
'<div class="majtas">'
if(!
$_GET['lkatid'] &&  !isset($_POST['do_edit']) &&  !isset($_POST['edit_katlajme'])) { 

echo 
$error

// Shfaq listen e kategorive 
lista_kategorilajmesh(); 





// Has the edit form been submitted? 

if(isset($_POST['do_edit'])) { 
     
    
$LKatID=  $_POST['LKatID']; 
    
$LKatEmri $_POST['LKatEmri']; 
    
$LKatLink $_POST['LKatLink']; 
    
$LKatAktiv $_POST['LKatAktiv']; 
     
    
$fshij =  $_POST['fshij']; 

     
    
// Ticked the 'delete category'  box? If so, delete and echo message.     
    
if($fshij== 'fshij_LKatID' && $error '') { 
         
    
$sql =  "DELETE FROM lajme_kategori WHERE  LKatID='$LKatID'"
    
$query =  mysql_query($sql) or die("Fatal error: ".mysql_error()); 

    echo 
"<h3>U Fshi</h3>"
    echo 
"<div  class='success_message'>Kategoria <b>$LKatID</b> u fshi  nga sistemi.</div>"
     
    echo 
"<h2>What to do  now?</h2><br />"
    echo 
"Go to the <a  href='katlajme_edit.php'>edit category</a> page.</li>"
         
    } else { 
     
    
// Validate the submitted  information 
     
        
if(trim($LKatID) == '1') { 
            
$error '<div  class="error_message">LKatID - Attention! You cannot edit the main  Administrator, use database.</div>'
        } else if(
trim($LKatEmri) == '') { 
            
$error '<div  class="error_message">LKatEmri - Attention! You must enter a first  name.</div>'
        } else if(
trim($LKatLink) == '') { 
            
$error '<div  class="error_message">LKatLink - Attention! You must enter a last  name.</div>'
        }  
         
    
// Password been entered? If so,  validate and update information. 
     
        
if(trim($LKatEmri) == '') { 
        
$error '<div  class="error_message">Attention! You must enter category  name.</div>'
          } else if(
trim($LKatLink) == '') { 
        
$error '<div  class="error_message">Attention! You must enter category  link.</div>'
        }  
             
            if(
$error == '') { 
         
            
$sql "UPDATE lajme_kategori  SET LKatEmri='$LKatEmri', LKatLink='$LKatLink', LKatAktiv='$LKatAktiv'  WHERE LKatID = '$LKatID'"
            
$query mysql_query($sql) or die("Fatal error: ".mysql_error()); 
         
            echo 
"<h2>U  Modifikua</h2>"
            echo 
"<div  class='success_message'>Kategoria u modifikua: <b>$LKatEmri  ($LKatLink)</b> me ID <b>$LKatID </b>.</div>"
             
            echo 
"<h2>What to do  now?</h2><br />"
            echo 
"Go to the <a  href='katlajme_edit.php'>edit category</a> page.</li>"
             
            } 
     
     
        } 
         
    } 


// Has a category been selected to  edit? 

if($_GET['lkatid'] && !isset($_POST['do_edit']) && !isset($_POST['edit_katlajme']) || $error != '') { 

    
$LKatID $_GET['lkatid']; 
     
    
$sql =  "SELECT * FROM lajme_kategori WHERE  LKatID='$LKatID'";  
    
$result mysql_query($sql); 
     
    
$row =  mysql_fetch_array($result); 
     
    
$LKatEmri $row['LKatEmri']; 
    
$LKatLink $row['LKatLink']; 
    
$LKatAktiv $row['LKatAktiv']; 
     
         
    echo 
$error
             
    echo 
"<h2>Informacionet per  kategorine ( ".stripslashes($row['LKatEmri'])." )</h2>"
     
?> 
 
<form action="" method="post"> 
<input type="hidden" name="LKatID" value="<?=$row['LKatID'];?>" /> 

<label>Emri Kategorise</label> 
<input type="text" name="LKatEmri" value="<?=stripslashes($row['LKatEmri']);?>"  style="width: 46%;" /><br /> 

<label>Link</label> 
<input type="text" name="LKatLink" value="<?=stripslashes($row['LKatLink']);?>"  /><br /> 

<label style="width: 50%;">Aktive</label> 
<input id="LKatAktiv" name="LKatAktiv" type="checkbox" <?php if ($LKatAktiv == "PO") { echo "checked";} ?> value="PO"> 
<br /><br /> 
<div class="error_message">Do fshish kete kategori? (Nuk  kthehet mbrapsh!) <input type="checkbox" class="checkbox"  name="fshij" value="fshij_LKatID"></div> 
<input type="submit" value="Ruaje" name="do_edit" /> 
</form> 

<? }  
echo 
'</div>'
include(
'poshte.php'); ?>
and the db table is:
Code:
-LKatID - init
-LKatEmri
-LKatLink
-LKatAktiv
Hooping that someone can help me with this issue!

Thank you in advance!
Kleidi is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-14-2010, 05:21 PM Re: Problem with delete function...
Experienced Talker

Posts: 32
Name: Kleidi
Trades: 0
It works now ... Was a quote and equal problem Sorry, My Fault!

Was:
PHP Code:
 // Ticked the 'delete category'  box? If so, delete and echo message.     
    
if($fshij== 'fshij_LKatID' && $error '') {
$sql =  "DELETE FROM lajme_kategori WHERE  LKatID='$LKatID'"
IS NOW
PHP Code:
// Ticked the 'delete category'  box? If so, delete and echo message.     
    
if($fshij== 'fshij_LKatID' && $error == '') { 
         
    
$sql =  "DELETE FROM lajme_kategori WHERE  LKatID=$LKatID"
Kleidi is offline
Reply With Quote
View Public Profile
 
Old 05-14-2010, 05:55 PM Re: Problem with delete function...
Novice Talker

Posts: 9
Trades: 0
Should also work as

PHP Code:
// Ticked the 'delete category'  box? If so, delete and echo message.     
    
if($fshij== 'fshij_LKatID' && $error == '') { 
         
    
$sql =  "DELETE FROM lajme_kategori WHERE  LKatID='".$LKatID."'"
</span></span>
DrewDown is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Problem with delete function...
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.67929 seconds with 12 queries