web技术编程练习题目

更新时间:2023-12-10 01:56:01 阅读量: 教育文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

作业1:

1.Create, test, and validate an XHTML document that describes an ordered list of your five favorite movies.

=

http://www.w3.org/1999/xhtml″>

My Favorite Movies

My Favorite Movies

    十二生肖

    哈利波特与死亡圣器 盗梦空间 阿甘正传 阿凡达

2.Create, test, and validate an XHTML document that describes a table with the following contents: The columns of the table must have the headings “Pine”, “Maple”, “Oak”, and “Fir”. The rows must have the labels “Average Height”, “Average Width”, “Typical Life Span”, and “Leaf Type”. You can make up the data cell values.

=

http://www.w3.org/1999/xhtml″>

Trees

Pine Maple Oak Fir

Average Height 20m 30m

40m 25m

Average Width 5m 6m 4.5m 4m

Typical Life Span 100y 80y 90y 110y

Leaf Type circle circle circle circle

3.Create, test, and validate an XHTML document that has a form with the following controls:?

a. A text box to collect the user’s name b. Four checkboxes, one each for the following items:

i. Four 100-watt light bulbs for $2.39 ii. Eight 100-watt light bulbs for $4.29

iii. Four 100-watt, long-life light bulbs for $3.95

iv. Eight 100-watt, long-life light bulbs for $7.49

c. A collection of three radio buttons that are labeled as follows: i. Visa ii. Master Card

iii. Discover

xmlns

=

http://www.w3.org/1999/xhtml″> 当当网

(yes|no) #REQUIRED>

2.Create an XML document with at least 4 door

2 speed automatic

radio

=

air_conditioning = \ power_windows = \ power_steering = \ \

作业2:

1.Create a DTD for a catalog of cars, where each car has the child elements make,

model, year, color, engine,

number_of_doors,

transmission_type,

and accessories. The engine element has the child elements number_of_cylinders and fuel_system (carbureted or fuel injected). The accessories element has the attributes

radio,

air_conditioning,

power_windows, power_steering, and power_brakes, each of which is required and has the possible values yes and no. Entities must be declared for the names of popular car models.

(#PCDATA)>

accessories

power_brakes three instances of the car element defined in the DTD of Exercise 1. Process this document by using the DTD of Exercise 1, and produce a display of the raw XML document.

SYSTEM

“./cars.dtd\

1997 &c; Impala Light blue

8

cylinder

multi-port fuel injected

4

door

4 speed automatic

2007 &f; Impala Light blue

8

cylinder

multi-port fuel injected

power_brakes = \

2000 &h; Impala Light pink

8

cylinder

multi-port fuel injected

4

door

4 speed automatic

3.Create an XML schema for the XML document described in Exercises 1 and 2.

xmlns:xsd=\

Schema\

xmlns=\rSchema\

targetNamespace=http://www.njupt.edu.cn/se/carSchema

elementFormDefault=\

mal\

作业3:

9.10 Write the XHTML code to create a form with the following capabilities: a. A text widget to collect the user’s name b. Four checkboxes, one each for the following items:

i. Four 100-watt light bulbs for $2.39 ii. Eight 100-watt light bulbs for $4.29 iii. Four 100-watt long-life light bulbs for

$3.95

iv. Eight 100-watt long-life light bulbs for $7.49

c. A collection of three radio buttons that are labeled as follows: i. Visa ii. MasterCard iii. Discover

html

PUBLIC

-//W3C//DTD XHTML 1.0 Strict//EN″ http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd>

xmlns

=

http://www.w3.org/1999/xhtml″> 当当网

9.11 Write a PHP script that computes the total cost of the ordered light bulbs from Exercise 9.10 after

adding 6.2 percent sales tax. The program must inform the buyer of exactly what was ordered, in a table.

xmlns

=

\ confirm

if( empty($_POST[\ $bulbs1=0;

else $bulbs1=$_POST[\if( empty($_POST[\ $bulbs2=0; else

$bulbs2 = $_POST[\

if( empty($_POST[\ $bulbs3=0; else

$bulbs3 = $_POST[\if( empty($_POST[\ $bulbs4=0; else

$bulbs4 = $_POST[\$payment=$_POST[\

$cost=$bulbs1+$bulbs2+$bulbs3+$bulbs4;

printf(\cost

is

$

%4.2f

\print(\if($bulbs1) print(\

Four 100-watt light bulbs for $2.39

\if($bulbs2)

print(\100-watt light bulbs for $4.29

\if($bulbs3)

print(\100-watt, long-life light bulbs for $3.95

\if($bulbs4)

print(\100-watt, long-life light bulbs for $7.49

\print(\payment

is

$payment

\?> 实验1:

1、个人主页代码:

欢迎访问姚雪宁的主页

width=800

height=550

background=\

padding-bottom=0px padding-left=0px padding-right=0px background=\

color=#FF0 padding-top=0px align=\

个人简介

个人经历简介:

width=200

height=150

src=\姚雪宁的照片\

个人经历

    1993年,出生于?? 2000年,进入小学 2005年,

    2008年,考入当地最好的高中,太谷第一中学

    2011年,以优异的成绩考入南京邮电大学

最喜欢的四本书

达芬奇密码 哈利波特与混血王子 红岩

福尔摩斯探案全集

个人兴趣简介

个人兴趣

友情链接

课程名 开课学期 任课教师 分数

高等数学 2012秋季 张三 90

高等数学 2012秋季 张三 90

高等数学 2012秋季 张三 90

数据结构 2014秋季 张三

90

大学物理 2012春季 李四 90

离散数学 2013秋季 王五 90

javascript脚本嵌入代码:

javascript 应用

实验二:

1.图书售卖界面代码:

xmlns

=

\

Welcome to book seller

You are welcome

please input you name:

please input your address:

please input your zip:

\ size = \

please fill in the quantity field of the following form

book publisher

price

quantity

Web technology Springer press

$5.0

size = \

mathematics

ACM press

$6.2

size = \

principle of OS Science press $10

\ size = \

Theory of matrix

High education press

$7.8

Payment Method

checked = \

cash

cheque

credit card

服务器端代码:

confirm your information

// Get form data values

if(empty($_POST[\else

$web = $_POST[\if(empty($_POST[\else

$math = $_POST[\if(empty($_POST[\else

$os = $_POST[\

if(empty($_POST[\else

$matrix = $_POST[\ $name = $_POST[\ $address = $_POST[\ $zip = $_POST[\

$payment = $_POST[\// Compute the item costs and total cost $web_cost = 5.0 * $web; $math_cost = 6.2 * $math; $os_cost = 10 * $os; $matrix_cost = 7.8 * $matrix; $total_price =

$web_cost

+ $math_cost +

$os_cost

+

$matrix_cost;

$total_items = $web + $math + $os + $matrix;

// Return the results to the browser in a table ?>

Customer:

$name

address: $address

zip: $zip

\ ?>

Order

Information

book publisher price total cost

=

%quot

center %quot>

Web technology Springer press $5.0 $web_cost \ ?>

if($math) print(\align

=

%quot

center %quot>

mathematics ACM press $6.2 $math_cost \

=

%quot

center %quot> principle of OS Science press $10

$os_cost \

if($matrix) print(\align

=

%quot

center %quot >

Theory of matrix High education press $7.8 $matrix_cost \

(\

has

bought

$total_items books
\

printf (\$total_price);

print (\ ?>

$fo=fopen(\

fwrite($fo,\has bought $total_items books,$name paid $total_price dollars,paid by $payment.\\r\\n\fclose($fo); ?> 实验三: Main.php代码:

~处理页面~

mysql_connect(\

if(!$conn) { die('Could

not connect:' . mysql_error());

}

?>

--------Create

database-------- */

$DB = \数据库名为Book_Seller

//判断数据库是否存在,

访问系统数据库information_schema

mysql_select_db(\a\or die(\选择失败!\//访问系统数据库 $sql =

\

schema_name from schemata limit 0,30\ $result_db

=

mysql_query($sql,$conn);

$bo = false;//创建bool型变量,用以判断

while($result

=

mysql_fetch_array($result_db,MYSQL_BO

TH)) {

//echo

$result[\

if($result[\== $DB)//数据库已存在,跳过就好啦~

{ $bo = true; break;

}

}

//开始判断

if(!$bo)//$bo=false,即该

数据库不存在,需要创建;存在的话就不管了

{

if(mysql_query(\database

Book_Seller\创建成功

{ //echo

\ } else { echo \

creating datablse: \ exit;

}

}

/* --------Create table in

Book_Seller database-------- */ //Use database $er =

mysql_select_db(\ if(!$er) { echo \_ Could not select the database\

exit;

}

//判断表是否存在,有三

个表,User,Book,Order_form,建个数组用循环语句实现 $tables = array(\\

$sqls = array(//User表语句

\table User(name varchar(20)

primary key not null, address varchar(100) not null, zip varchar(10) )\表语句

\

book varchar(20) primary key not null, publisher varchar(50) not null,

price double)\表语句 \

id int not null auto_increment primary key, name varchar(20) not null, book varchar(20) not null, quantity int not null,

foreign key (name) references User(name), foreign key (book) references Book(book))\); for($i=0; $i<3; $i++)//遍历数组

{

//判断表是否存在

if(mysql_num_rows(mysql_query(\ow tables like '\不存在,建表 {

$sql

=

$sqls[$i];

if(mysql_query($sql, $conn)) { //echo

$tables[$i] . \创建成功\

}

else { echo $tables[$i] . \创建失败\

exit;

}

}

}

?>

//查询用户是否存在

$result

=

mysql_query(\count(*) as num from User where name='\. $_POST['name'] . \ $r

=

mysql_fetch_array($result);

if($r[\< 1)//该用户不存在,添加

{

$sql = \into

User values('\$_POST['name'] .\$_POST['address'] .\ if(!mysql_query($sql, $conn))

{ die('ERROR: ' .

mysql_error());

}

}

else //用户存在,修改信

息 {

$sql = %user set address='\$_POST['zip'] .\

where

name='\

$_POST['name'] .\

if(!mysql_query($sql, $conn))

{ die('ERROR: ' .

mysql_error());

} }

/* ----------插入数据,第

二张表 Book------------ */ //为书名建数组

$books

=

array(\

technology\of

OS\

//查询书籍是否存在,4本书 //Web technology

$result

=

mysql_query(\count(*) as num from Book where book='\ $r

=

mysql_fetch_array($result);

if($r[\< 1)//书籍不

存在,添加

{

$sql = \into

Book values('\$books[0] .\press','5.0')\ if(!mysql_query($sql, $conn))

{ die('ERROR: ' .

mysql_error());

}

}

//mathematics

$result

=

mysql_query(\count(*) as num from Book where book='\ $r

=

mysql_fetch_array($result);

if($r[\< 1)//书籍不存在,添加

{

$sql = \into Book values('\$books[1]

.\

press','6.2')\

if(!mysql_query($sql, $conn))

{ die('ERROR: ' .

mysql_error());

}

}

//principle of OS

$result

=

mysql_query(\count(*) as num from Book where book='\

$r = mysql_fetch_array($result);

if($r[\< 1)//书籍不存在,添加

{

$sql = \into Book values('\$books[2] .\press','10')\ if(!mysql_query($sql, $conn))

{ die('ERROR: ' .

mysql_error());

}

}

//Theory of matrix

$result

=

mysql_query(\count(*) as num from Book where book='\ $r

=

mysql_fetch_array($result);

if($r[\< 1)//书籍不存在,添加 {

$sql = \into Book values('\$books[3]

.\

education press','7.8')\

if(!mysql_query($sql, $conn))

{ die('ERROR: ' .

mysql_error());

}

}

/* ----------插入数据,第三张表 Order_form------------ */ //建数量数组

$quantities

=

array($_POST['web'],$_POST['math'],$_POST['os'],$_POST['matrix']); //检查数量项是否为空。不为空则添加进表,为空则不管

for($i=0; $i<4; $i++) {

if(!empty($quantities[$i]))

{ //判断数据库是否存在此条信息

$result

=

mysql_query(\count(*) as num from Order_form where name='\$_POST['name'] .\and book='\

$books[$i] .\

$r

=

mysql_fetch_array($result); if($r[\< 1)//书籍不存在,添加

{

$sql

=

\values('\$_POST['name'] .\

$books[$i] .\

if(!mysql_query($sql, $conn))

{

die('ERROR: ' . mysql_error());

} }

else //书籍存在,更改数量信息

{

$sql

=

\$quantities[$i] .\where name='\$_POST['name'] .\and

book='\

$books[$i] .\

if(!mysql_query($sql, $conn))

{

die('ERROR: ' . mysql_error());

} } }

}

?>

//关闭连接 mysql_close($conn); ?>

//select.php

订单查询





if(isset($_POST['submit'])) { ?>

//建立连接 $conn =

mysql_connect(\ if(!$conn) { die('Could

not connect:' . mysql_error());

}

//Use database $er =

mysql_select_db(\

if(!$er) { die('ERROR:

'

. mysql_error()); }

?>

$sql = \o.name

name,o.book book,b.publisher

publisher,o.quantity quantity,b.price price from

book

b,order_form

o

where

b.book=o.book and o.name='\

$_POST['name'] .\

$result =

mysql_query($sql, $conn); if(!$result) {

die('ERROR: '

.

mysql_error());

}

//总金额存放处 $allcost = 0.0;

//显示结果

print \查询结果:\

$num

=

mysql_num_rows($result);

if($num < 1)//结果集为空 {

print \该用户没有

订单\

}else {

//开始画表格 print

\

border='1' cellspacing='0' cellpadding='0'>\

//第一行标题 print \

align='center'>\ print \ print \ print \ print \

print \ //查询内容 while($row = mysql_fetch_assoc($result))

{

print \align='center'>\

print

\

$row['name'] .\

print \$row['book'] .\ print \$row['publisher'] .\

print

\

$row['quantity'] .\ print \ $allcost +=

$row['quantity'] * $row['price'];

}

//显示总金额

print \align='right'>\

print

\colspan='4'>总金额: \

print \ print \

}

?>

?>

}

?>

本文来源:https://www.bwwdw.com/article/jq95.html

Top