感觉mysql里面的东西好多,很容易忘记,不是很熟练,知道某些函数有某种功能,但就是想不起来函数的名字,需要去翻笔记,真的还需要大量的练习,毕竟这块的内容可以说是全新的...不知道后面做项目怎么样,这两天的话连一天的视频都没看完,主要是怕看的太多,知识还没巩固好,这样看也没什么效果,还是一边看一边做题目有意思.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>用户表</title>
<script type="text/javascript" src='jquery.js'></script>
<script type="text/javascript">
var span_obj = document.getElementsByTagName("span");
$(function(){ $("#username").focus(function(){
span_obj[0].innerHTML = "<font color='red'>字母开头,后跟数字或字母,至少3位,,至多10位</font>";
})
$("#userpwd").focus(function(){
span_obj[1].innerHTML = "<font color='red'>任意组合,3到10位</font>";
})
})
</script>
</head>
<body>
<form action="mysql_show_info.php" method="post">
<table width="600" border="1" align="center">
<tr>
<td align="right">用户名:</td>
<td><input type="text" name="username" id='username'></td>
<td width="350" ><span></span></td>
</tr>
<tr>
<td align="right">密码:</td>
<td><input type="password" name="userpwd" id="userpwd"></td>
<td ><span></span></td>
</tr>
<tr>
<td align="right">年龄:</td>
<td colspan='2'><input type="text" name="age"></td>
</tr>
<tr>
<td align="right">学历:</td>
<td colspan="2">
<select name="edu">
<option>请选择</option>
<option value="1">小学</option>
<option value="2">初中</option>
<option value="3">高中</option>
<option value="4">大学</option>
<option value="5">硕士</option>
</select>
</td>
</tr>
<tr>
<td align="right">爱好:</td>
<td colspan="2">
<input type="checkbox" name="hobbies[]" value="1">排球
<input type="checkbox" name="hobbies[]" value="2">篮球
<input type="checkbox" name="hobbies[]" value="4">足球
<input type="checkbox" name="hobbies[]" value="8">中国足球
<input type="checkbox" name="hobbies[]" value="16">地球
<input type="checkbox" name="hobbies[]" value="32">火星
</td>
</tr>
<tr>
<td align="right">来自:</td>
<td colspan="2">
<input type="radio" name="position" value="1">东北
<input type="radio" name="position" value="2">华北
<input type="radio" name="position" value="3">西北
<input type="radio" name="position" value="4">华东
<input type="radio" name="position" value="5">华南
<input type="radio" name="position" value="6">华西
</td>
</tr>
<tr align="center">
<td colspan="3"><input type="submit" value="OK"></td>
</tr>
</table>
</form>
</body>
</html>
<?php
//连接数据库
$link = mysql_connect("localhost","root","admin");
mysql_query("set names utf8");
mysql_query("use db1");
//创建表
mysql_query("create table if not exists show_info (
userid int auto_increment primary key,
username varchar(10) not null unique key,
userpwd varchar(48) not null,
age tinyint not null,
edu enum('小学','初中','高中','大学','硕士') not null,
hobbies set('排球','篮球','足球','中国足球','地球','火星') not null,
position enum('东北','华北','西北','华东','华南','华西') not null,
ot datetime
) ");
//获取表单提交的内容
$username = $_POST['username'];
$userpwd = $_POST['userpwd'];
$age = $_POST['age'];
$edu = $_POST['edu'];
$hobbies = $_POST['hobbies'];
$hobbies = array_sum($hobbies);
$position = $_POST['position'];
//将获得的数据插入数据库中
$sql = "insert into show_info (username,userpwd,age,edu,hobbies,position,ot) values";
$sql .= "('$username',md5('$userpwd'),$age,$edu,$hobbies,$position,now())";
//echo $sql;
mysql_query($sql);
//输出显示表的标题
$title = mysql_query("select * from show_info");
$title_count = mysql_num_fields($title);
echo "<table border='1'>";
echo "<tr>";
for($i=0;$i<$title_count;++$i){
$title_field = mysql_field_name($title,$i);
echo "<td>".$title_field."</td>";
}
//输出每一项
$result = mysql_query("select * from show_info");
while($rec=mysql_fetch_array($result)){
echo "<tr>";
echo "<td>{$rec['userid']}</td>";
echo "<td>{$rec['username']}</td>";
echo "<td>{$rec['userpwd']}</td>";
echo "<td>{$rec['age']}</td>";
echo "<td>{$rec['edu']}</td>";
echo "<td>{$rec['hobbies']}</td>";
echo "<td>{$rec['position']}</td>";
echo "<td>{$rec['ot']}</td>";
echo "</tr>";
}
echo "</table>";
?>

目前还只是做成这个样子,还需要不断琢磨完善...

5th day的更多相关文章

  1. C++Primer 5th 练习 12.19

    这阵子真是太忙了, 连续做了四个课设. 当然这并不能作为好久没写博客的借口, 没写博客的主要原因只有一个: 懒. 最近又开始回顾C++的语法与特性(据说C++就是一门需要反复回顾的语言),以及学习C+ ...

  2. The 5th tip of DB Query Analyzer

    The 5th tip of DB Query Analyzer             Ma Genfeng   (Guangdong UnitollServices incorporated, G ...

  3. 【读书笔记】C++ primer 5th 从入门到自闭(一)

    这几天看了C++ primer 5th的一二章,有很多收获,但是有的地方因为翻译的问题也搞得理解起来颇为难受啊啊啊啊.尤其是const限定符,在C语言并没有这么多复杂的语法,在C++里面语法细节就多的 ...

  4. Spring In Action 5th中的一些错误

    引言 最近开始学习Spring,了解到<Spring实战>已经出到第五版了,遂打算跟着<Spring实战(第五版)>来入门Spring,没想到这书一点也不严谨,才看到第三章就发 ...

  5. October 5th 2016 Week 41st Wednesday

    Don't follow the crowd, let the crowd follow you. 不要随波逐流,要引领潮流. But to be a good follower is already ...

  6. Spetember 5th 2016 Week 37th Monday

    No matter how far you may fly, never forget where you come from. 无论你能飞多远,都别忘了你来自何方. Stay true to you ...

  7. July 5th, Week 28th Tuesday, 2016

    If you smile when no one else is around, you really mean it. 独处的时候你的笑容才是发自内心的笑容. Human beings are so ...

  8. c++ primer 5th 练习3.43

    #include <iostream> using namespace std; int main() { ][]={,,,,,,,,,,,}; /* for(int (&i)[4 ...

  9. August 5th, 2016, Week 32nd, Friday

    Life is made up of small pleasures. 生活由各种细小的幸福构成. Don't expect too much. I am not qualified to get m ...

  10. nenu contest3 The 5th Zhejiang Provincial Collegiate Programming Contest

    ZOJ Problem Set - 2965 Accurately Say "CocaCola"!  http://acm.zju.edu.cn/onlinejudge/showP ...

随机推荐

  1. JS & JQuery 动态添加 select option

    因为是转载文章 在此标明出处,以前有文章是转的没标明的请谅解,因为有些已经无法找到出处,或者与其它原因. 如有冒犯请联系本人,或删除,或标明出处. 因为好的文章,以前只想收藏,但连接有时候会失效,所以 ...

  2. java 保留小数点后N位数(若干位),几种实现的方式总结

    import java.math.BigDecimal;import java.text.DecimalFormat;import java.text.NumberFormat;/** * java ...

  3. Invalid project description overlaps the location of another project [android]

    解决办法: 1.将工程放到其他目录下,然后执行Android工程的导入,导入时可以选择“Copy projects into workspace”: 2.不用Android工程导入,而用普通的工程导入 ...

  4. 常见的iis日志代码!

    2xx  成功 200  正常:请求已完成. 201  正常:紧接 POST 命令. 202  正常:已接受用于处理,但处理尚未完成. 203  正常:部分信息 — 返回的信息只是一部分. 204   ...

  5. 命令模式(Command)

    1.本质: 封装请求 2.定义: 把一个请求封装为一个对象,从而使你可用不同的请求对客户进行参数化,对请求排队或记录请求日志,以及支持可撤销的操作 3.核心: 原本“行为请求者”和“行为执行者”是紧紧 ...

  6. Linux设置固定IP

    此处需整理 问题:在CentOS 7上,我想要将我其中一个网络接口从DHCP改为静态IP地址配置,如何才能永久为CentOS或RHEL 7上的网络接口分配静态IP地址? 如果你想要为CentOS 7中 ...

  7. POJ2524-宗教问题-并查集-ACM

    太难的搞不过,只能来写简单的了 POJ2524 无所不在的宗教 世界上宗教何其多.假设你对自己学校的学生总共有多少种宗教信仰很感兴趣.学校有n个学生,但是你不能直接问学生的信仰,不然他会感到很不舒服的 ...

  8. dede导航设置成单页面内容

    有时顶级导航可能就是一个单页面 如公司简介 联系我们等 方法一:直接在导航栏填写内容 常规设置 二高级选项设置模板 三 填写页面内容 四 模板页面调用 内容 可在栏目模板中用{dede:field.c ...

  9. python类class基础

              44.class类:                      一.类定义的一般形式:                            1.简单的形式:实例化对象没有自己独有 ...

  10. odoo view field option, action flage 参数

    options JSON object specifying configuration option for the field's widget (including default widget ...