当前位置:Gxlcms > PHP教程 > 添加数据,显示添加行为成功,但是输入的数据显示是0

添加数据,显示添加行为成功,但是输入的数据显示是0

时间:2021-07-01 10:21:17 帮助过:8人阅读

在做一个添加分类的功能。
添加成功后,返回界面。
看到添加这个分类这个行为确实成功了(多出一个分类条),但是本应该是显示新增分类名的位置显示的却是数字0...


回复讨论(解决方案)

无代码,无真相

初学阶段,现在是用smarty写的。附代码


一.修改分类的php代码


header("Content-Type:text/html;charset=utf-8");
include_once '../smarty/Smarty.class.php';
include_once '../dbio/NewsTypes.php';
$smarty=new Smarty();
$act=$_GET['act'];
$typeId=$_GET['typeId'];
$typeName=$_POST['typeName'];
$newsTypes=NewsTypes::getNewsTypes();
if ($act=="delete") {
$result=NewsTypes::delNewsType($typeId);
header("location:success.php?act=deltype&rst={$result}");
}else if($act=="update"){
$result=NewsTypes::updateNewsType($typeId,$typeName);
header("location:success.php?act=modtype&rst={$result}");
}
$smarty->assign("newsTypes",$newsTypes);
$smarty->assign("typeId",$typeId);
$smarty->assign("typeName",$typeName);
$smarty->display('modtype.html');

。。。。发错了。。。。。

。。。实在不好意思 重发


一.添加分类的PHP代码
header("Content-Type:text/html;charset=utf-8");
include_once '../smarty/Smarty.class.php';
include_once '../dbio/NewsTypes.php';
$smarty= new Smarty();
$typeName=$_POST['typeName'];
var_dump($typeName);
if ($typeName!=null) {
$result=NewsTypes::addNewsTypes($typeName);
header("location:success.php?act=addtype&rst={$result}");
}
$smarty->display("addtype.html");

人气教程排行