用PHP搭建学生信息管理平台
PHP,即Hypertext Preprocessor,是一种内嵌在网页中由服务器端来执行的程序。它具有跨平台、面向对象及与数据库集成完美等特性,为广大网页程序员所青睐。
MySQL采用了关联数据库的结构,是一套精简、快速的数据库管理程序。它提供了多人使用的管理功能,并支持标准的SQL语法。与PHP同样具有跨平台的功能。
用PHP4+MySQL+Win98(PWS)来构建一个信息平台是可以实现的。在本文中笔者以一个简单的学生信息管理系统为例,谈谈自己的亲身经历,以飨读
者。
第一步,安装服务器
要将WIN98平台的计算机作为服务器,必须安装PWS(Personal Web Server)。读者可以在Win98光盘中的add-onspws目录中找到,直接运行setup.exe即可。
安装完成后,在硬盘中新建一个目录(D:php)专门存放php文件。运行PWS,进入界面后,单击“高级”,进入高级选项界面,再单击“添加”按钮,新建一个虚拟目录php,选定D:php为其目录,注意勾选【执行】选项。
第二步,安装PHP4
将PHP4的文件放在C:php4中,将php4ts.dll,msvcrt.dll复制到C:windowssystem中,将php.ini-dist改名为php.ini,复制到c:windows中。
还需配置php.ini,具体如下:
extension_dir=C:/php/extensions
asp_tags = On ; 允许使用ASP风格的标记,即 browscap = C:windowssysteminetsrvrowscap.ini (因为用的服务器是PWS)
读者还可以发现在php.ini中很多行前面都有“;”号,这表示注释行。配置PHP还需将如下各行前面的分号去掉。
extension =php_ldap.dll (LDAP功能)
extension =php_zlib.dll (ZLib功能)
extension =php_calendar.dll(日历转换功能)
extension =php_exif.dll (EXIF功能)
extension =php_ftp.dll
extension =php_mssql70.dll
extension =php_imap.dll
再进入C:php4 sapi目录,运行PWS-php4isapi.reg,更改注册表。执行regedit,打开注册表编辑器,打开HKEY_LOCAL_MACHINE | system | CurrentControlSet | Services | W3SVC | Parameters | Script Map,右键单击该主键,在弹出的快捷菜单中选择【新建|串值】,命名为.php (即PHP网页的扩展名,也可以是.php4、.phtml或其他),将其值设定为:c:php4sapiphp4isapi.dll。关闭注册表编辑器即可。
第三步,安装MySQL
运行MySQL的安装程序setup.exe,MYSQL就安装到C:mysql中。将该目录下的my-example.cnf改名为my.cnf,复制到C盘根目录下。
运行C:mysqlin目录中的mysqld.exe (或mysqld-shareware.exe),MySQL开始启动。以后如果希望用户能够浏览查询数据库,都必须运行该文件,以启动数据库。
我们还必须设置MySQL数据库的管理员账号(root)与密码(123456):在DOS界面下进入c:mysqlin,输入命令行mysqladmin-u root password 123456即可。
如此一来,PHP4+MySQL+Win98(PWS)已安装并设置完成。
第四步,添加数据
先启动MySQL数据库,然后在DOS窗口中,执行mysql-u root -p命令行,再输入密码,开始编辑数据库。具体操作步骤如下:
1.创建数据库data,即C:mysqldata目录。
mysql >create database data;
mysql >use data
2.在数据库data中创建表student
mysql>create table student(
->stu_no Char(6) Not Null,
->name Char(8),
->birthday Date,
->math_score Tinyint
->Primary Key(stu_no)
->);
3.在C:mysqldata目录下新建文本文档student.txt,按各字段的顺序输入记录,每个字段间以Tab字符间隔。
4.将student.txt中的记录导入到表student中。其中 表示Tab字符,表示回车符。
mysql>Load Data Infile 'student.txt' Into table student
->Fields Terminated By ' '
->Lines Terminated By ' ';
第五步,编写PHP程序
在记事本中输入如下代码,将其另存为test.php,保存在D:php目录下。
If(!Mysql_connect("localhost","root","123456"))
echo "连接数据库失败";
Elseif(!Mysql_select_db("data"))
echo "打开数据库失败";
sql = "select * from student";
records = Mysql_query( sql);
?>
&nbs
p;
tr bgcolor=blue>学号
姓名
生日
数学科成绩
tr>
While(List( stu_no, name, birthday, math_score)=Mysql_fetch_row( records))
{
echo "". stu_no."
".."
". birthday."
". math_score."
tr>";
}
?>
在浏览器中输入http://127.0.0.1/php/test.php,可以看到如图5所示的效果。当然这必须建立在所有的设置均无误的基础上,记得启动PWS和MySQL哦!
作为一名教育工作者,管理学生的信息尤为重要。本文只是起到抛砖引玉的作用,我们可以充实这个系统,使其具备查询、更新、删除信息等功能。这样一来,管理浩繁的学生信息将不再难了!
对于其他行业的PHP爱好者而言,能在Win98平台下享受PHP的乐趣,也不失为一大快事。祝愿大家做出更多更好的作品。

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

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



MySQL is an open source relational database management system, mainly used to store and retrieve data quickly and reliably. Its working principle includes client requests, query resolution, execution of queries and return results. Examples of usage include creating tables, inserting and querying data, and advanced features such as JOIN operations. Common errors involve SQL syntax, data types, and permissions, and optimization suggestions include the use of indexes, optimized queries, and partitioning of tables.

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

PHP remains important in modern web development, especially in content management and e-commerce platforms. 1) PHP has a rich ecosystem and strong framework support, such as Laravel and Symfony. 2) Performance optimization can be achieved through OPcache and Nginx. 3) PHP8.0 introduces JIT compiler to improve performance. 4) Cloud-native applications are deployed through Docker and Kubernetes to improve flexibility and scalability.

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

MySQL is chosen for its performance, reliability, ease of use, and community support. 1.MySQL provides efficient data storage and retrieval functions, supporting multiple data types and advanced query operations. 2. Adopt client-server architecture and multiple storage engines to support transaction and query optimization. 3. Easy to use, supports a variety of operating systems and programming languages. 4. Have strong community support and provide rich resources and solutions.

The reasons why PHP is the preferred technology stack for many websites include its ease of use, strong community support, and widespread use. 1) Easy to learn and use, suitable for beginners. 2) Have a huge developer community and rich resources. 3) Widely used in WordPress, Drupal and other platforms. 4) Integrate tightly with web servers to simplify development deployment.

MySQL's position in databases and programming is very important. It is an open source relational database management system that is widely used in various application scenarios. 1) MySQL provides efficient data storage, organization and retrieval functions, supporting Web, mobile and enterprise-level systems. 2) It uses a client-server architecture, supports multiple storage engines and index optimization. 3) Basic usages include creating tables and inserting data, and advanced usages involve multi-table JOINs and complex queries. 4) Frequently asked questions such as SQL syntax errors and performance issues can be debugged through the EXPLAIN command and slow query log. 5) Performance optimization methods include rational use of indexes, optimized query and use of caches. Best practices include using transactions and PreparedStatemen

PHP and Python each have their own advantages and are suitable for different scenarios. 1.PHP is suitable for web development and provides built-in web servers and rich function libraries. 2. Python is suitable for data science and machine learning, with concise syntax and a powerful standard library. When choosing, it should be decided based on project requirements.
