php by oneself

在php里面写html代码真的很麻烦,最近学到了一个新的方法:

<html>
<head>
    <title>PHP</title>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
</head>
<body>
    <?php
       for($i=0;$i<5;$i++){
    ?>
    <table>
        <tr>
            <td>语文</td>
            <td>数学</td>
        </tr>
        <tr>
            <td>90</td>
            <td>89</td>
        </tr>
    </table>
    <?php
        }
    ?>
</body>
</html>

 

WAMPSEVER是个很轻大的软件,集合了Apache、PHP、MySQL,用起来也方便;

在PHPstorm里面导入MySQL也方便:

 1 <html>
 2 <head>
 3     <title></title>
 4     <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
 5 </head>
 6 <body>
 7 <?php
 8 if(@$_POST['submit']){
 9     $name = $_POST['name'];
10     $sex = $_POST['sex'];
11     $add = $_POST['add'];
12     $conn = @mysql_connect("localhost","root","root") or die("数据库连接失败,请检查你的网络,稍后再试试");
13     mysql_select_db("students");
14     mysql_query("set names 'utf8'");
15 
16     $sql = "INSERT INTO `test`.`students` (`id`,`name`, `sex`, `add`) VALUES (NULL, '$name', '$sex', '$add')";
17     mysql_query($sql);
18 
19 }
20 ?>
21 
22 <form action="studAdd01.php" method="post">
23     用户名: <input type="text" name="name"/> <br/>
24     性别:   <input type="text" name="sex"/> <br/>
25     住址:   <input type="text" name="add"/><br/>
26             <input type="submit" name="submit" value="提交"/> <br/>
27 </form>
28 </body>
29 </html>

 

posted @ 2014-04-25 23:25  moemiss  阅读(204)  评论(0编辑  收藏  举报