15-7. 论坛系统-父板块添加功能实现

Users expect the dynamic effect that black icon can represent after clicking corresponding icon.

So then how to realize it by php?

<li><a <?php if(basename($_SERVER['SCRIPT_FILENAME'])=='father_module.php'){echo 'class="current"';}?> href="father_module.php">Father Module List</a></li>

In order to solve the problem, we can use if statement to judge whether the current page is the page which user click or not.

But It how do we get the php file name of current page. PHP provide $_GET to help us get acquire the current page url

and also provide basename() to help us extract the current php file name. At last, add the style to the Menu bar

which meet the condition.

 

When user click the menu bar, the title in browser also should be change to the corresponding name of menu bar.

So then how to realize it?

The father_module.php and father_module_add.php use the common header.php.

We can store the title name in a array, and assign the different name element to different page title.

Certainly, the definition of the variable should be did before the header.php which was included in the homepage.

 

In front-end page, we often use link to import css or js file, sometimes the css files are troublesome

to import, so then how to import css or js file more easily by PHP?

The solution method is similar with the problem of represent title name in browser.

We can store all the css file paths in a array and assign it to the same array.

Next step, foreach them in the header.php.

 

How to add a father module into database without errors appear, such as input restriction,

input type and avoid repeated module name was created?

The data can be transferred from input box to father_module_add.php by the method of $_GET,

and then use SQL statement to store the data in database. In a general way, the module name and

sort value should not be empty, so we should make a judgement on users’ information of input box after

they submitted it. The length restriction of module name and numeric type of number also should be set,

otherwise error would appear.In order to make special chars like quotation mark can be stored in database ,

the data which was received from users need to be escaped before stored in database.

 

In order to avoid that the repeated module name be created, we need to use

SQL statement select * from js_father_module where module_name='{$_POST['module_name']}' to

query whether exist the same module name already in database.

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值