2014-02-18 3 views
-1

관리자가 삭제 버튼을 추가하고 싶지만 작동하지 못합니다. 여기에 내 코드 (주석 라인 모두, 내가 그들을 시도)입니다 :관리자의 데이터베이스에서 행을 삭제합니다.

`<?php ` 
`$db = JFactory::getDBO();` 



`$query = $db->getQuery(true);` 

/* ----------------- STERGERE -----------------------*/ 

    `if(isset($_GET['delete'])) 
    { $query->delete('*'); 

     $query->from('roy_testimonial'); 

     $query->where('testimonial_id = "'.$_GET['delete'].'"'); 

     $db->setQuery($query); 

    }` 
/* ----------------- END STERGERE -----------------------*/ 
/*-------------- AFISARE ------------------ */ 

`$query->select('*');` 

`$query->from('roy_testimonial');` 


`$db->setQuery($query);` 

`$options = $db->loadAssocList();` 

`foreach($options as $row) { 

    $firstname = htmlentities($row['firstname']); 

    $lastname = htmlentities($row['lastname']); 

    $city = htmlentities($row['city']); 

    $state = htmlentities($row['state']); 

    $mesaj = htmlentities($row['user_mesaj']); 

    $purchase = htmlentities($row['your_purchase']); 

    $sales = htmlentities($row['sales']); 

    $financing = htmlentities($row['financing']); 

    $service = htmlentities($row['service']); 

    $parts = htmlentities($row['parts']); 

    $accesories = htmlentities($row['accesories']); 

    $id = $row['testimonial_id'];` 

/* ----------------- END AFISARE -----------------------*/ 


`?>` 

`<div style="float:left;width:600px;">` 

`<h2 style="color:#015CB7;"><?php echo $id; ?>) <?php echo $firstname;?> <?php echo $lastname;?>` 

`<font style="color:#000;font-size:14px;">(<?php echo $city;echo ','; echo $state;?>)</font></h2>` 

`<p>` 

`<font style="font-size:14px;font-weight:bold;">Mesaj:</font> <?php echo $mesaj; ?></p>` 

`</div>` 

`<div style="float:left;width:300px;">` 

<!-- RATING --> 

`<h2 style="color:#015CB7">Rating</h2>` 

`Your Purchase: <?php echo $purchase; ?> <br/>` 

`Sales: <?php echo $sales; ?> <br/>` 

`Financing and Insurance: <?php echo $financing; ?> <br/>` 

`Service: <?php echo $service; ?> <br/>` 

`Parts: <?php echo $parts; ?> <br/>` 

`Accesories: <?php echo $accesories; ?> <br/>` 

`</div>` 

`<div style="float:right;width:300px;">` 

`<a href="?delete=<?=$id;?>">Sterge</a>` 
`</div>` 

`<div style="clear:both;"></div>` 



`<?php } ?>` 

이것은 내가 지금까지 가지고 내가 할 대신에 게시물을 사용해야 무엇인가?

+0

후 그리고'exact' 오류는 무엇인가? http://stackoverflow.com/help/mcve – kmas

+0

아무런 오류가 없으며 행을 삭제하지 않고 있습니다. – RMissy

+1

안녕하세요, 좋습니다. 우선 사용하지 않는 코드를 모두 제거하십시오. 그러면 훨씬 쉽게 읽을 수 있습니다. 둘째,'$ _GET'을 사용하지 말고 [this] (http://docs.joomla.org/Retrieving_request_data_using_JInput)에서 읽으십시오. 'delete' 실행을 위해 두 데이터베이스 쿼리 메소드를 주석 처리했습니다. 어느 것이 사용하고 있습니까? – Lodder

답변

0

실제로 쿼리를 설정했지만 실행하지 않았습니다. 추가 다음

$db->query();

$db->setQuery($query); 
+0

고마워요,하지만 똑같습니다. – RMissy

+0

$ db-> setQuery()와 $ db-> query()가 다르다. 어쨌든 어떤 쿼리가 실행될 지 알려준다. echo $ query-> dump(); 그런 다음 쿼리가 잘 설정되었는지 확인할 수 있습니다. –

+0

미안하지만, 나는 당신의 아이디어도 사용했다는 것을 의미합니다. 작동하지 않습니다. – RMissy

관련 문제