【发布时间】:2014-03-18 08:13:15
【问题描述】:
我有一个组件,我想在管理员中添加一个删除按钮,但我无法让它工作。这是我的代码(所有注释的行,我都试过了):
`<?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 } ?>`
这是我目前所拥有的,我应该使用 post 代替 get 吗?
【问题讨论】:
-
exact错误是什么? stackoverflow.com/help/mcve -
我没有任何错误,只是没有删除我的行。
-
嗨,好的,首先,删除所有你不使用的代码,这样会更容易阅读。其次,不要使用
$_GET,请阅读this。您已经注释掉了delete执行的两种数据库查询方法,您使用的是哪一种? -
好的,我会阅读该页面。谢谢。
-
@RMissy - 请使用您正在使用的代码编辑您的问题,并删除您不使用的任何代码
标签: database joomla delete-row corresponding-records