php原生链接mysql,并读取数据

admin2年前PHP707
<?php
header("Content-type:text/html;charset=utf-8");
set_time_limit(0);

//连接数据库
$con = mysqli_connect("localhost", "root", "root", "dyfilmold");
if (!$con) {
    die('Could not connect: ' . mysqli_error());
}
mysqli_query($con, 'SET NAMES UTF8');

$numsQuery = mysqli_query($con, "select count(*) from ay_content where scode = 1");
$numsQuery2 = mysqli_fetch_row($numsQuery);
$nums = $numsQuery2[0];

$page = intval($_GET['page']);if(empty($page)) $page=1;
$nextpage = $page+1;
$pagesize = 100;

$pages = ceil($nums/$pagesize);
$firstR = ($page-1)*$pagesize;

//连接数据库
$con2 = mysqli_connect("localhost", "root", "root", "dyfilm");
if (!$con2) {
    die('Could not connect: ' . mysqli_error());
}
mysqli_query($con2, 'SET NAMES UTF8');



$r = mysqli_query($con, "select * from ay_content where scode = 1 order by id desc limit $firstR,$pagesize");
while($v = mysqli_fetch_assoc($r)){
    $aid = $v['id'];
    $title = addslashes($v['title']);
    $content = str_replace(['2023-02-27'], ['/2023-02-27'], addslashes($v['content']));
    $seo_title = '';
    $seo_keywords = addslashes($v['keywords']);
    $seo_description = addslashes($v['description']);
    $litpic = '';
    $lx = addslashes(trim($v['lx']));
    $dw = addslashes(trim($v['dw']));
    $author = addslashes(trim($v['author']));
    $source = addslashes(trim($v['source']));
    $sort_order = intval(trim($v['sorting']));
    $add_time = strtotime(trim($v['create_time']));
    $update_time = strtotime(trim($v['update_time']));
    $click = intval($v['visits']);

    $sql = "insert into dyfilm_archives(aid,typeid,title,channel,is_litpic,litpic,click,arcrank,seo_title,seo_keywords,seo_description,sort_order,lang,add_time,update_time,author,origin) values($aid, 1, '".$title."', 1, 0, '', $click, 0, '$seo_title','$seo_keywords','$seo_description','1000','cn','$add_time','$update_time','$author','$source');";


    $rs = mysqli_query($con2, $sql);
    if (!$rs) {
        die($sql);
    }

    $sql = "insert into dyfilm_article_content(aid,content,add_time,update_time) values($aid,'$content','$add_time','$add_time')";
    mysqli_query($con2, $sql);


}
if($nextpage <= $pages){
    $url = '?page='.$nextpage;
    echo '<!doctype html><html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8"></head><body><script>window.setTimeout(function(){window.location.href="'.$url.'"}, 1000)</script></body></html>';
}else{
    exit('已完成');
}

?>


相关文章

安装Composer报错php_igbinary.dll' - 找不到指定的模块。

首先去php\php-7.1.13-nts\ext中找,并未发现有php_igbinary.dll文件,然后去该网站下载适合自己的文件 网址:https://windows.php.net/downl...

2023年最新的28道PHP面试题附答案

https://www.swvq.com/boutique/detail/6734...

php切片上传

html    <style>        html {...

opencart教程 上传产品

opencart教程 上传产品

点击左边导航【商品目录】【商品管理】点击右上角加号,新增商品填写数据时,以下是必填分类选择如下...

opencart paypal 体验账号测试支付

opencart paypal 体验账号测试支付

很多朋友在设置独立站后台Paypal收款时,经常看到Live和Sandbox这两个字眼。是否会产生疑惑:这是干什么的呢?其实这里的LIVE模式是正常付款环境下的付款模式,Sandbox就是我们所说的沙...

PayPal Payments Standard如何设置?

paypal账户登录后,依次点击setting - 账户设置 - 产品与服务 - 网站付款 - 网站习惯设定自动返回开启,填写URL付款数据传输 开启创建sandbox账号https://develo...

发表评论    

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。