原生CURD

<?php
header("content-type:text/html;charset=utf8");
$link=mysqli_connect("127.0.0.1","root","","1611a");
mysqli_query($link,"set names utf8");
$page=isset($_GET['page'])?$_GET['page']:1;
if($page<1){
$page=1;
}
$size=3;
$sql1="select*from xing left join leixing on xing.lei=leixing.cid ";
$res1=mysqli_query($link,$sql1);
$arr1=mysqli_fetch_all($res1,1);
$num=count($arr1);
$end=ceil($num/$size);php

$forset=($page-1)*$size;
$sql="select*from xing left join leixing on xing.lei=leixing.cid limit $forset,$size";
$res=mysqli_query($link,$sql);
$arr=mysqli_fetch_all($res,1);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<input type="text"><button>查詢</button>
<table border="1">
<tr>
<td>企業編號</td>
<td>企業名稱</td>
<td>法人名稱</td>
<td>證件號碼</td>
<td>公司類型</td>
<td>email地址</td>
<td>企業名片</td>
<td>操做</td>
</tr>
<?php foreach ($arr as $key => $value){?>


<tr>
<td><?php echo $value['bh']?></td>
<td><?php echo $value['user']?></td>
<td><?php echo $value['cuser']?></td>
<td><?php echo $value['card']?></td>
<td><?php echo $value['type']?></td>
<td><?php echo $value['emai']?></td>
<td><img src=" <?php echo $value['img']?>" alt="" width="100"></td>
<td><a href="#" onclick="sc(<?php echo $value['id']?>)">刪除</a>|<a href="#">修改</a></td>
</tr>
<?php }?>
</table>
<a href="show.php?page=<?php echo $page-1?>">上一頁</a>
<a href="show.php?page=<?php echo $page+1?>">下一頁</a>
<a href="show.php?page=1?>">首頁</a>
<a href="show.php?page=<?php echo $end?>">尾頁</a>html


</body>
</html>
<script>
function sc(id){
a=new XMLHttpRequest()
a.open("get","delete.php?id="+id)
a.send()
a.onreadystatechange=function(){
if(a.readyState==4&&a.status==200){
location.href=""
}
}
}
</script>mysql

 

//添加sql

<?php
header("content-type:text/html;charset=utf8");
$link=mysqli_connect("127.0.0.1","root","","1611a");
mysqli_query($link,"set names utf8");
$bh=$_POST['bh'];
$user=$_POST['user'];
$cuser=$_POST['cuser'];
$card=$_POST['card'];
$lei=$_POST['lei'];
$email=$_POST['emai'];
$file=$_FILES['img'];
$name=$file['name'];
$tmp=$file['tmp_name'];
move_uploaded_file($tmp,$name);
$sql="insert into xing values(null,'$bh','$user','$cuser','$card','$lei','$email','$name')";
$res=mysqli_query($link,$sql);
if($res){
echo "<a href='show.php'>上傳成功</a>";
}else{
echo "<a href='good.php>上傳失敗</a>";
}fetch

相關文章
相關標籤/搜索