各位高手,我是个初学者,最近做php时,从数据库得的数不能在 页面显示,请帮忙,非常感你们。
过程如下:
mysql 数据库中一个表为 school_grade
内容如下:
gradeId gradeName gradeState
2012 12级 毕业
2013 12级 在校
下面用的是smaryt
1 model层为:
class manaModel
{
public function showGrade(){
//这是用于显示年级的
$sqlHelper=new SqlHelper();
$sql="select * from school_grade";
$result=$sqlHelper->execute_selectArray($sql);
$sqlHelper->close_connect();
return $result;
}
}
2 控制层为:
require_once '../models/manaModle.class.php';
$dataModel=new manaModle();//实例 化用户模板
$smarty->assign("res_grade",$dataModel->showGrade());//用于显示年级
$smarty->display("manager.html");
?>
3 view(templates)层:
年级设置
年级编号 | 年级名称 | 年级状态 |
|
我想在显示表格中,有一个select 中,12级为毕业,那就显示为“毕业”,13级人在校,select 中选中"在校",同时,内部的两种状态还存在,请况代码如何写,用javascript也可以,请帮外忙,我将非常感激。
回复讨论(解决方案)
不知道smaryt的标签怎么用 先试试吧
不明白你的意思,选中的标准是什么?
在需要选中的option上加入
例如
这种方法我试过了,不能根据$mess.gradeState的值来判断哪个值被选中,执行结果都为‘毕业’,
但也非常感谢了。
这种方法我试过了,不能根据$mess.gradeState的值来判断哪个值被选中,执行结果都为‘毕业’,
但也非常感谢了。
为什么两个option的value都是{$mess.gradeState},这里有问题吧,另外你说不能根据$mess.gradeState的值来判断哪个值被选中,这就奇怪了,可以这样测试
echo $mess.gradeState;
var_dump($mess.gradeState=='在校');
看看输出什么。
这种方法我试过了,不能根据$mess.gradeState的值来判断哪个值被选中,执行结果都为‘毕业’,
但也非常感谢了。
那你打印$mess.gradeState出来看下是什么
这种方法我试过了,不能根据$mess.gradeState的值来判断哪个值被选中,执行结果都为‘毕业’,
但也非常感谢了。
那你打印$mess.gradeState出来看下是什么
在控制层打印如下:
Array
(
[0] => Array
(
[gradeId] => 127
[gradeName] => 13级
[gradeState] => 在校
)
[1] => Array
(
[gradeId] => 127
[gradeName] => 12级
[gradeState] => 毕业
)
)
但是,在view层 ";?>打印不出结果。用 一句在页面的打印出的结果为:在校 毕业
{$mess.gradeState}能分别输出 在校和毕业是吗
那用6楼的var_dump($mess.gradeState=='在校'); 看看是不是boolean类型 是不是true
{$mess.gradeState}能分别输出 在校和毕业是吗
那用6楼的var_dump($mess.gradeState=='在校'); 看看是不是boolean类型 是不是true
不能输出,显示不出boolean 类型。
这是不因我用的是smarty模板的原因啊,因为整个操作都在 teplates中进行了,按理说,smaryt应该是显示与逻辑分开的,我在显示是用了逻辑,请高手指点一下。这种情况如何解决。
充填 option,smarty 有专门的方法 http://www.111cn.net/phper/122/smarty_html_options_select.htm
充填 option,smarty 有专门的方法 http://www.111cn.net/phper/122/smarty_html_options_select.htm
这几天我一直研究这个问题,但总找不到如何进行判断。
问题没有解决,含泪感谢大家。
请大家继续到这个地文坛帮我:
http://blog.csdn.net/yuxuefa/article/details/39855827

Thedifferencebetweenunset()andsession_destroy()isthatunset()clearsspecificsessionvariableswhilekeepingthesessionactive,whereassession_destroy()terminatestheentiresession.1)Useunset()toremovespecificsessionvariableswithoutaffectingthesession'soveralls

Stickysessionsensureuserrequestsareroutedtothesameserverforsessiondataconsistency.1)SessionIdentificationassignsuserstoserversusingcookiesorURLmodifications.2)ConsistentRoutingdirectssubsequentrequeststothesameserver.3)LoadBalancingdistributesnewuser

PHPoffersvarioussessionsavehandlers:1)Files:Default,simplebutmaybottleneckonhigh-trafficsites.2)Memcached:High-performance,idealforspeed-criticalapplications.3)Redis:SimilartoMemcached,withaddedpersistence.4)Databases:Offerscontrol,usefulforintegrati

Session in PHP is a mechanism for saving user data on the server side to maintain state between multiple requests. Specifically, 1) the session is started by the session_start() function, and data is stored and read through the $_SESSION super global array; 2) the session data is stored in the server's temporary files by default, but can be optimized through database or memory storage; 3) the session can be used to realize user login status tracking and shopping cart management functions; 4) Pay attention to the secure transmission and performance optimization of the session to ensure the security and efficiency of the application.

PHPsessionsstartwithsession_start(),whichgeneratesauniqueIDandcreatesaserverfile;theypersistacrossrequestsandcanbemanuallyendedwithsession_destroy().1)Sessionsbeginwhensession_start()iscalled,creatingauniqueIDandserverfile.2)Theycontinueasdataisloade

Absolute session timeout starts at the time of session creation, while an idle session timeout starts at the time of user's no operation. Absolute session timeout is suitable for scenarios where strict control of the session life cycle is required, such as financial applications; idle session timeout is suitable for applications that want users to keep their session active for a long time, such as social media.

The server session failure can be solved through the following steps: 1. Check the server configuration to ensure that the session is set correctly. 2. Verify client cookies, confirm that the browser supports it and send it correctly. 3. Check session storage services, such as Redis, to ensure that they are running normally. 4. Review the application code to ensure the correct session logic. Through these steps, conversation problems can be effectively diagnosed and repaired and user experience can be improved.

session_start()iscrucialinPHPformanagingusersessions.1)Itinitiatesanewsessionifnoneexists,2)resumesanexistingsession,and3)setsasessioncookieforcontinuityacrossrequests,enablingapplicationslikeuserauthenticationandpersonalizedcontent.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

SublimeText3 Linux new version
SublimeText3 Linux latest version

Dreamweaver Mac version
Visual web development tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.
