在php中使用AJAX CRUD的建议

时间:2014-02-17 15:39:36

标签: php ajax

我有两个问题,首先是AJAX CRUD无法正常工作,我不知道为什么。我整个周末都试图解决这个问题,但没有。问题是我可以在没有刷新网站的情况下向动态数据库添加内容,但我无法删除它并在不刷新的情况下进行编辑和更新。接下来就是我的语言符号没有正确显示。

我试图添加,但仍然没有。

这是我的网站代码

<?php

//demo the issue
require_once('preheader.php'); // <-- this include file MUST go first before any HTML/output

    require_once('ajaxCRUD.class.php');

?>

<html>
<head>
<META HTTP-EQUIV="content-type" CONTENT="text/html; charset=iso-8859-2">

<link rel="stylesheet" type="text/css" href="menugora.css" />
<link rel="stylesheet" type="text/css" href="login_success.css" />
</head>
<body>
<div id=menu>

<li> <a href="login_success.php?menu=2">Item</a> </li>

</div>



<?php

$arg = (int)$_GET['menu'];

switch ($arg)
{
case 1:
    include('Item.php');
break;

}

?>
</body>
</html>

这是我的item.php

<html>


<META HTTP-EQUIV="content-type" CONTENT="text/html; charset=iso-8859-2">

<link rel="stylesheet" href="format.css" type="text/css">
<body>
<?php


# this one line of code is how you implement the class
$tblCustomer = new ajaxCRUD("Towar","Towar", "Tow_id");

# don't show the primary key in the table
$tblCustomer->omitPrimaryKey();


# my db fields all have prefixes;
# display headers as reasonable titles
$tblCustomer->displayAs("Tow_nazwa", "Nazwa");
$tblCustomer->displayAs("Tow_opis", "Opis");
$tblCustomer->displayAs("Tow_producent", "Producent");
$tblCustomer->displayAs("Tow_nr_czesci", "Numer części");
$tblCustomer->displayAs("Tow_cena", "Cena");
$tblCustomer->displayAs("Tow_ilosc", "Ilość");
$tblCustomer->displayAs("Kat_id", "Numer kategorii");

# add the filter box (above the table)
$tblCustomer->addAjaxFilterBox("Tow_nazwa");

# add validation to certain fields (via jquery in validation.js)
$tblCustomer->modifyFieldWithClass("Tow_nazwa", "Nazwa produktu");

# actually show to the table
$tblCustomer->showTable();

?>

</body>
</html>

ajaxcrud的链接也在这里http://ajaxcrud.com/    我想补充一点,db charset是utf8_polish_ci。感谢所有线索,建议和帮助。

2 个答案:

答案 0 :(得分:0)

Ajaxcrud在幕后对您查看的同一页面网址做了一些动态请求,但可能并不总是保留该部分?完整。看看你如何将item.php包含在内,尝试其他方式并查看ajaxcrud的代码。我一直在大型系统上使用它,并且在以这种方式使用时几乎没有扭结。

另外,对于编码,至少在preheader.php,javascript文件,php.ini,mysql数据库和网页本身中都有编码。为方便起见,所有应设置为UTF-8。

答案 1 :(得分:0)

好的,这是跟踪过滤器的技巧。 Ajaxcrud创建了一堆$ _SESSIONS变量,因此在使用该类之前首先加载where子句:

$_SESSION['ajaxcrud_where_clause']=$WhereClause;

在调用显示器(showtable)后添加这个短序列时,您可能会遇到一些警告。

$tblCustomer->showTable();
    if(isset($_SESSION['ajaxcrud_where_clause']))
    {
        $WhereClause =$_SESSION['ajaxcrud_where_clause'];

    }