$arr_chk=$_POST['extra'];
$str_rdo=$_POST['hospital'];print_r($arr_chk);//数组
echo $str_rdo;//string
$str_rdo=$_POST['hospital'];print_r($arr_chk);//数组
echo $str_rdo;//string
解决方案 »
- 请问php如何将一维数组的值分割成数组?
- mysql查询多条数据的问题
- 怎样判断用户已登录?
- 求大虾帮助!user=".$_GET['user']." 这个表达式什么意思
- 注册的时候,有验证码,但是还是有很多垃圾会员,这是怎么回事?
- include LoadLang("pub/fun.php");这句是什么意思,新手
- 我想开发一个基于web中小型企业的员工管理系统?用PHP写,但是我的编程工具用什么啊?
- 求助!怎样使用www.domainbank.net申请的INFO域名啊?
- 请大家帮帮我啊!!!!!!
- 俺最近想好好研究一下apache,睡能推荐本好书?
- 关于编辑器的应用
- mysql字符集问题 MD5
xxx换成你表单想取值的name
$str_rdo=$_POST['hospital'];print_r($arr_chk);//数组
echo $str_rdo;//string
$firstName=$_POST['fname']; //First name
$lastName=$_POST['lname'];//Last name
$phoneNumber=$_POST['pnumber'];//Phone number
$hospitalCover=$_POST['hospital'];//Hospital cover
$extraHealthCover=$_POST['extra'];//Extra health coverecho $firstName."<br>";
echo $lastName."<br>";
echo $phoneNumber."<br>";
echo $hospitalCover."<br>";
print_r($extraHealthCover);
?>
message ‘You selected no extra cover' instead of the list of extra cover.
The following information can be used to calculate the premium:
Table 1-1 lists the cost of hospital cover for individuals, couples and families.
Each item of optional extra cover costs $50 for individuals i.e. $50 for dental, $50 for optical, and so on.
The cost of optional extra cover for couples is 2 times the cost of optional extra cover for
individuals i.e. $100 for dental, $100 for optical, and so on.
The cost of optional extra cover for families is 3 times the cost of optional extra cover for
individuals i.e. $150 for dental, $150 for optical, and so on.Table 1-1. Hospital cover costs
Type of hospital cover Cost
Individual $1 300
Couple $2 500
Family $3 200If the prospective customer does not supply a first name, last name, phone number or type of hospital
cover on the form, the results page should tell the customer that the missing detail is required and ask
him or her to click the browser's Back button and try again. Processing of the form should stop at that
point.
The following examples illustrate how the premium is calculated.
Example 1. An individual wants to buy hospital cover, optional dental cover, optional optical cover and
optional physiotherapy cover. The cost is $1 450.
$1 300 + $50 + $50 + 50 = $1 450
Example 3. A family wants to buy hospital cover, optional optical cover and optional physiotherapy
cover. The cost is $3 500.
$3 200 + ($50 + $50) 3 = $3 500
@$fname=$_POST["fname"];
@$lname=$_POST["lname"];
@$pnumber=$_POST["pnumber"];
@$hospital=$_POST["hospital"];
@$extra=$_POST["extra"];if ($fname=="" or $lname=="" or $pnumber=="" or $hospital==""){ //资料没有填写完整
echo "Provide you with incomplete information";
exit();
}if ($extra==""){ //计算一共选了多少项附加
$count=0;
}else{
$count = count($extra);
}if ($count==0){
echo "You selected no extra cover <br>"; //提示不用支付其它项
}
if ($hospital=="Individual"){ //判断是以那种身份参加医疗保险
$total= 1300 + 50 * $count;
echo "You paid a total " . $total; //个人
}else if ($hospital=="Couple"){
$total= 2500 + (50 * $count) * 2;
echo "You paid a total " . $total; //夫妻
}else if ($hospital=="Family"){
$total= 2500 + (50 * $count) * 3;
echo "You paid a total " . $total; //家庭
}
?>有什么错接着说
$total= 2500 + (50 * $count) * 3;
echo "You paid a total " . $total; //家庭
}改为else if ($hospital=="Family"){
$total= 3200 + (50 * $count) * 3;
echo "You paid a total " . $total; //家庭
}
写错了
Craft School is a fictitious institution that runs hobby classes. The aim of this question is to a build a
MySQL database and a PHP page that retrieves and formats records from the store’s database of courses
and instructors.
Creating the database
Start phpMyAdmin and create a new database named assignment2. Within the assignment2 database,
create a table named instructors with the fields shown in Table 2–1. Create a primary key on the
instructor_id field and set the auto_increment option for that field. Fill the table with the data shown in
Table 2–2 and save the table.
Table 2–1: Fields for the instructors table
Field name Data type Field description
instructor_id unsigned int ID number that uniquely identifies an instructor
instructor_name varchar(30) Instructor's name
instructor_phone varchar(20) Instructor's phone number
Table 2–2: Data for the instructors table
instructor_id instructor_name instructor_phone
1 Kerry Walters 5294 1140
2 John Jacobson 5407 1006
3 Jessica Cameron 5499 7387
4 Bruce Phillips 5314 4212
Create a second table named courses with the fields shown in Table 2–3. Create a primary key on the course_id field and set the auto_increment option for that field. Fill the table with the data shown in Table 2–4 and save the table.
Table 2–3: Fields for the courses table
Field name Data type Field description
course_id unsigned int ID number that uniquely identifies a course
course_name varchar(30) Name of course
instructor_id unsigned int ID number that uniquely identifies the course instructor
course_start date Starting date of course
course_weeks unsigned int Length of course in weeks
course_cost unsigned decimal(5,2) Cost of course
Table 2–4: Data for the courses table
course_id course_name instructor_id course_start course_weeks course_cost
1 Introductory Pottery 3 2009-11-09 6 180.00
2 Cake Decorating 1 2009-10-26 8 240.00
3 Advanced Pottery 3 2010-01-11 6 180.00
4 Introductory Photography 4 2009-10-26 6 150.00
5 Advanced Photography 4 2010-01-18 6 150.00
6 Signwriting 2 2010-01-11 8 240.00
Use phpMyAdmin to add a new user named student with all privileges on all tables in the assignment2
database. Set the user's password to mmst12009.
It is very important that you create this user with the name, password and privileges that have been
specified because the er will test your code with these details. If you give your user a different
name, a different password or different privileges, your code will fail to work on the er's computer.
Creating the list page
Create a PHP file named list.php that retrieves the following details for all courses in the database: the
course ID number, name, starting date, length in weeks, cost and instructor name.
Display these details in an XHTML table with the column headings that appear in Figure 2–1. The
records should be sorted by course ID number in ascending order.
Currency values should be displayed with a leading dollar sign ($) and two decimal places. You must
format any currency values in your PHP code. Do not rely on MySQL to format currency values.
Dates should be displayed as the day of the month in digits (no leading 0 for single-digit days), followed
by the full name of the month, followed by the year represented as 4 digits. You must format any date
values in your PHP code. Do not rely on MySQL to format date values.
前面接收单选按钮和复选框传过来的值的问题已经让9楼帮我解决了。现在的问题我在11楼和12楼里面说清楚了,就是写出list.php这个程序。非常感谢大家的帮助,尤其感谢9楼。
create database assignment2;
use assignment2;
create table Instructor(
instructor_id int(10) not null auto_increment,
instructor_name varchar(30),
instructor_phone varchar(30),
primary key(instructor_id)
);
insert into Instructor values('','Kerry Walters','5294 1140');
insert into Instructor values('','John Jacobson','5407 1006');
insert into Instructor values('','Jessica Cameron','5499 7387');
insert into Instructor values('','Bruce Phillips','5314 4212');
create table course(
course_id int(10) not null auto_increment,
course_name varchar(30),
instructor_id int(10),
course_start datetime,
course_weeks bigint,
course_cost decimal(5,2),
primary key(course_id)
);
insert into course values('','Introductory Pottery',3,' 2009-11-09',6,180.00);
insert into course values('','Cake Decorating',1,' 2009-10-26',8,240.00);
insert into course values('','Advanced Pottery',3,' 2010-01-11',6,180.00);
insert into course values('','Introductory Photography',4,' 2009-20-26',6,150.00);
insert into course values('','Advanced Photography',4,'2010-01-18',6,150.00);
insert into course values('','Signwriting',2,'2010-01-11',8,240.00);Grant all
On assignment2
To mmst12009 identified by "mmst12009"list.php要的内容看不太懂 我再看下
谢谢楼上,我翻译了一下:
创建列表页面
创建一个PHP文件命名为list.php以下细节中所有课程中:
课程名称、身份证号码,在周开始日期、长度、成本和教练的名字。
这个记录应根据课程的身份证号码顺序。
货币价值应展示了美元($)和两个标志小数。你必须在你的任何一种货币价值的格式的PHP代码。不要依靠货币价值函数的格式。
日期应表现为每月的数字(0领先于为单数天),跟着由姓名,紧随其后的是年度表现为4位数。你必须格式的任何日期在你的PHP代码的价值。不要依靠日期值函数的格式。