Home >Backend Development >PHP Tutorial >添加数据,显示添加行为成功,但是输入的数据显示是0

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

WBOY
WBOYOriginal
2016-06-23 13:01:59995browse

在做一个添加分类的功能。
添加成功后,返回界面。
看到添加这个分类这个行为确实成功了(多出一个分类条),但是本应该是显示新增分类名的位置显示的却是数字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");

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn