PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
-- SELECT user, host FROM mysql.user; SHOW DATABASES; SHOW PROCESSLIST; SHOW GRANTS; -- echo "CREATE USER "${domain}"@"localhost" IDENTIFIED BY \"${dbup}\";" | mysql -u root -p"${dbrp}" -- echo "CREATE DATABASE ${domain};" | mysql -u root -p"${dbrp}" -- echo "GRANT ALL PRIVILEGES ON ${domain}.* TO ${domain}@localhost;" | mysql -u root -p"${dbrp}" -- CREATE USER domain @ localhost IDENTIFIED BY dbup; | mysql -u root -p dbrp -- CREATE DATABASE domain; | mysql -u root -p dbrp -- GRANT ALL PRIVILEGES ON domain.* TO domain @localhost; | mysql -u root -p dbrp -- SELECT * FROM information_schema.processlist; -- SELECT ID , user, host, db, command -- FROM information_schema.processlist -- WHERE ID = CONNECTION_ID(); -- CREATE USER IF NOT EXISTS 'emp_read_only'@'localhost' IDENTIFIED BY 'TestPassword'; -- SELECT * FROM mysql.user; -- SELECT user(); -- SELECT current_user(); -- SELECT DATABASE(); DROP TABLE IF EXISTS `student1`; CREATE TABLE `student1` ( `id` int(10) NOT NULL AUTO_INCREMENT, `name` varchar(15) DEFAULT NULL, `sex` char(4) DEFAULT NULL, `address` varchar(20) DEFAULT NULL, `hobby` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8; DROP TABLE IF EXISTS `student2`; CREATE TABLE `student2` ( `id` int(10) NOT NULL AUTO_INCREMENT, `name` varchar(15) DEFAULT NULL, `sex` char(4) DEFAULT NULL, `address` varchar(20) DEFAULT NULL, `hobby` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8; CREATE TEMPORARY TABLE student3 ( `id` int(10) NOT NULL AUTO_INCREMENT, `name` varchar(15) DEFAULT NULL, `sex` char(4) DEFAULT NULL, `address` varchar(20) DEFAULT NULL, `hobby` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8; DESC student1; -- SHOW DATABASES; SHOW TABLES; -- use information_schema; -- SHOW TABLES; -- use sakila; -- SHOW TABLES; -- SELECT DATABASE(); /* -- 创建临时表 CREATE TEMPORARY TABLE temp_orders AS SELECT * FROM orders WHERE order_date >= '2023-01-01'; -- 查询临时表 SELECT * FROM temp_orders; -- 插入数据到临时表 INSERT INTO temp_orders (order_id, customer_id, order_date) VALUES (1001, 1, '2023-01-05'); -- 查询临时表 SELECT * FROM temp_orders; -- 删除临时表 DROP TEMPORARY TABLE IF EXISTS temp_orders; */
Copy Clear
Copy Format Clear
<?php echo date('Y-m-d H:i:s').PHP_EOL.PHP_EOL; $conn = $mysqli; if($conn->connect_error){ die('Connect Failed:'.$conn->connect_error); } // if(isset($_POST["name"])&&isset($_POST["sex"])&&isset($_POST["address"])&&isset($_POST["hobby"])) { // $name=$_POST["name"]; // $sex=$_POST["sex"]; // $address=$_POST["address"]; // $hobby=$_POST["hobby"]; // $hobbies=implode(",",$hobby); $name="nameA"; $sex="sexA"; $address="addressA"; $hobby="hobbyA"; $hobbies=implode(",",$hobby); echo "hobbies: ".$hobbies; $sql = "INSERT into student (name,sex,address,hobby) VALUES ('$name','$sex','$address','$hobbies')"; if (mysqli_query($conn, $sql)) { echo "新记录插入成功"; } else { echo "Error: " . $sql . "<br>" . mysqli_error($conn); } } //修改业务(接收来自updatestudent.php页面传来的Post提交的参数) // if(isset($_POST["name2"])&&isset($_POST["sex2"])&&isset($_POST["address2"])&&isset($_POST["hobby2"])&&isset($_POST["id"])){ // $id=$_POST["id"]; // $name2=$_POST["name2"]; // $sex2=$_POST["sex2"]; // $address2=$_POST["address2"]; // $hobby2=$_POST["hobby2"]; // $hobbies2=implode(",",$hobby2); // $sqlupdate = "UPDATE student SET NAME='$name2',sex='$sex2',address='$address2',hobby='$hobbies2' WHERE id=$id"; // if (mysqli_query($conn, $sqlupdate)) { // echo "<script>alert('修改成功')</script>"; // // header("Location: service.php"); //刷新当前页面 // mysqli_close($conn); // } else { // echo "Error: " . $sqlupdate . "<br>" . mysqli_error($conn); // } // } //查询,返回全部结果 // $sqlselect="select * from student"; // $result=mysqli_query($conn, $sqlselect); // if($result->num_rows>0){ // echo "<h1>学生信息显示</h1>"; // echo "<div><a href='student_form.php'>添加学生</a></div><br>"; // echo "<table><tr><th>姓名</th><th>性别</th><th>地址</th><th>爱好</th><th>操作</th></tr>"; // while($row=$result->fetch_assoc()){ // echo '<tr><td>'.$row["name"].'</td> // <td>'.$row["sex"].'</td> // <td>'.$row["address"].'</td> // <td>'.$row["hobby"].'</td> // <td> // <a href="service.php?id='.$row["id"].'">删除</a>'.' '. // '<a href="updatestudent.php?id='.$row["id"].'">修改</a></td></tr>'; // } // echo "</table>"; // }else{ // echo "0个结果"; // } //删除业务,接受本页面传来的id参数,利用此参数删除对应记录 // if(isset($_GET["id"])){ // $id=$_GET["id"]; // $sqldelete='delete from student where id='.$id; // if (mysqli_query($conn, $sqldelete)) { // echo "<script>alert('删除成功')</script>"; // mysqli_close($conn); // // header("Location: service.php"); //刷新当前页面 // } else { // echo "Error: " . $sqldelete . "<br>" . mysqli_error($conn); // } // } ?>
Show:  
Copy Clear