After following, you can keep track of his dynamic information in a timely manner
Courses in the relevant section:Database construction for PHP development login page
<?php header("Content-type:text/html;charset=utf-8"); $servername="localhost"; $username="root"; $password=""; $conn = mysqli_connect($servername,$username,$password); mysqli_set_charset($conn,'utf8'); if(!$conn){ die("链接失败:" . mysqli_connect_error()); } $sql = "CREATE DATABASE login"; if(mysql_query($conn,$sql)){ echo "数据库创建成功"; }else{ echo "数据库创建失败:" . mysql_error($conn); } mysqli_close($conn); ?>
2018-05-100个赞
Courses in the relevant section:Regular delimiter
推荐::‘/’或‘#’作为定界符
2018-05-140个赞
Courses in the relevant section:Database Design
create database onecms;//创建数据库 create table message( id int(11) not null primary key auto_increment, title varchar(255) NOT NULL, content text NOT NULL) ENGINT=innoDB DEFAULT CHARSET=utf8;
2018-05-090个赞
Courses in the relevant section:Add function to message page
<form action="insertdb.php" method="post"> 标题:<input type="text" id="title" name="title"><br> 内容:<br><span><textarea name="content" rows="13" cols="80" id="content"></textarea> <script> KindEditor.ready(fonction(K){ window.editor = K.create('#content',{ afterBlur:function(){this.sync(); } }) }) </script> </span> <input type="submit" name="dosub" id="btn" value="上传留言"> </form>
2018-05-090个赞
Courses in the relevant section:Database Connectivity
<?php //conn.inc.php define("HOST",'localhost'); define("USER",'root'); define("PWD",'root'); ?> <?php //mysqli.php include 'conn.inc.php'; $mysqli=new mysqli(HOST,USER,PWD,DBNADM); if($mysqli->connect_errno){ die('数据库链接出错'.$mysqli->connect_error); } ?>
2018-05-090个赞
Courses in the relevant section:Message page display function
include 'mysqli.php'; $sql="select * from message"; $result=$mysqli->query($sql); if($result->num_rows>0){ while($row=$result->fetch_assoc()){ $arr[$row["id"]]["title"]=$row["title"];//$arr[1]["title"]=$row["title"] $arr[$row["id"]]["content"]=$row["content"];//$arr[1]["content"]=$arr["content"] } } echo json_encode($arr);
2018-05-090个赞
Courses in the relevant section:Overall code display
$page= isset($_GET["page"])?$_GET["page"]:1; $num=isset($_GET["num"])?$_GET["num"]:4 $startnum=($page-1)*$num;
2018-05-090个赞