1.html网页前台显示
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
ul{
list-style-type: none; /*清除无序列表前的小点*/
width: auto;
height: 50px;
background: #3b3753;
margin: 0px;
padding-left: 20%;/*左边距,使li看起来在中间*/
/*position: relative;*/
text-align: center;
}
li{
float: left;
width: 130px;
height: 100%;
padding: 0px;
margin-right: 1%; /*两个li之间的距离*/
}
a:link,a:visited{ /*鼠标未点击和点击过时的样式*/
display: block;
color: #FFFFFF;
background-color: #3b3753;
text-align: center;
line-height: 30px; /*li行高*/
padding: 10px;
text-decoration: none; /*去下划线*/
}
a:hover{ /*鼠标移动到点击位时的样式,active指点击过后的样式*/
background-color: #111;
}
</style>
</head>
<body>
<div class="box">
<div class="nav1">
<!--横向导航栏-->
<ul>
<li><a href="sdfj.php"> 项目1 </a></li>
<li><a href="index.php"> 首页 </a></li>
<li><a href="#"> 项目3 </a></li>
<li><a href="#"> 项目4 </a></li>
<li><a href="#"> 项i目5 </a></li>
</ul>
</div>
<div>
</body>
</html>
————————————————
版权声明:本文为CSDN博主「小白学安全hhhh」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/2303_79592445/article/details/135727986
2.数据库链接
<?php
$conn=mysqli_connect('localhost','root','输入的密码','fly');
$sql="select * from sdsadas ";
$result=mysqli_query($conn,$sql);
while($row=mysqli_fetch_array($result))
{
echo $row['id'];
echo $row['content'];echo "<br>";
}
?>
3.get传参指定的数据库内容
<?php
$conn=mysqli_connect('localhost','root','密码','fly');
$i=$_GET['x'];//********
$sql="select * from sdsadas where id='$i' ";//*********
$result=mysqli_query($conn,$sql);
while($row=mysqli_fetch_array($result))
{
echo $row['id'];
echo $row['content'];echo "<br>";
}
?>
但在url中加入?x=1,则可以输出数据库所对应的内容http://localhost/sdfj.php?x=1这样它将调用数据库中的内容http://localhost/sdfj.php?x=1
4.利用配置型文件
首先建立一个文件conn.php里面放入配置型文件
<?php
$conn=mysqli_connect('localhost','root','密码','fly');?>
接着在源文件去引用他
<?php
//$conn=mysqli_connect('localhost','root','cqh13322052748','fly');
include ("conn.php");//配置型文件的引用
$i=$_GET['x'];
$sql="select * from sdsadas where id='$i' ";
$result=mysqli_query($conn,$sql);
while($row=mysqli_fetch_array($result))
{
echo $row['id'];
echo $row['content'];echo "<br>";
}
?>
5.get和post的传参(为什么是不能是post无法传出来)
<?php
$x=$_GET['x'];
echo $x;
$f=$_POST['y'];
echo $f;
?>
此时当你输入y的传参时他不会显示任何东西,因为url只能支持get传参不支持post传参所以想post传参需要通过hackbar的工具
但将其改成request则在post和get的状态下都可以接受request的传参
主句库的使用