Hongmu Notes
Home Language Notes php sql read and write operation database
Language Notes PHP PHP collection PHP and mysql

php sql read and write operation database

php sql read and write operation database

I am about to learn object-oriented, so some code needs to be deleted. Let’s make a record here.
This string of code is mainly used for writing operations in the empire database, etc.

<?php
// header('content-type:text/html;charset=utf-8;');
// header('content-type:application/json;charset=utf-8');
define('DB_NAME', 'rming');
define('DB_USER', 'rming');
define('DB_PASSWORD', 'Px6nCaaYESbMHmST');
define('DB_HOST', 'localhost');
define('DB_CHARSET', 'utf8');
define('DB_PREFIX', 'phome_');

// 检测连接
if (!$conn = @mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME)) {
    die("<b>PHP链接MYSQL数据库出现错误!请检查配置!</b>");
}
//选择数据库
if(!mysqli_select_db($conn,DB_NAME)){
    die("<b>PHP选择MYSQL数据库出现错误!请检查配置!</b>");
}
$pages = 300;

//设置字符集
mysqli_set_charset($conn,DB_CHARSET);

$id = $_GET['id']-1;

//执行SQL语句
$select = mysqli_query($conn,'SELECT * FROM `phome_author` ORDER BY `id` ASC  limit '.$pages*$id.','.$pages.'');
$where = '';
while($arr = mysqli_fetch_array($select)){
    $where .= "(NULL, '$arr[booker]', '', '')".',';
}

$where = rtrim($where,',');
$where = "INSERT INTO `phome_booker` (`id`, `booker`, `bookerurl`, `bookid`) VALUES " . $where;
echo $where;
// $arr = mysqli_fetch_all($select,MYSQLI_ASSOC);
// print_r(json_encode($arr));

// 
//关闭数据库
mysqli_close($conn);
微信赞赏

WeChat

支付宝赞赏

Alipay

✍️ Author: Hong Mu

webmaster · Thanks for reading, stay tuned for more exciting content

Author homepage View home page →

Related articles

PHP cast type

PHP cast type Language Notes PHP PHP collection PHP and mysql

Get the data type 1. If you want to check the value and type of an expression, use var_dump(). 2. If you just want to get an easy-to-read type expression for debugging, use gettype(). 3. To check a certain type, do not use gettype(), but use the is_type() function. Converting Strings to Numbers When a string is evaluated as a number, the result is determined according to the following rules...
👁 232
PHP special character escaping and restoration

PHP special character escaping and restoration Language Notes PHP PHP collection PHP and mysql

Escape character is a special character constant. Escape characters are backslashed " & quot; At the beginning, followed by one or more characters. The escaped character has a specific meaning, which is different from the original meaning of the character, so it is called "escaped" character. The use of escape characters 1: turn ordinary characters into special purposes, such as back key and enter key. 2. Used to convert a character with special meaning back to its original meaning. 3. Before data is written into the database, escape characters (function …
👁 180
mysqli in PHP

mysqli in PHP Language Notes PHP PHP collection PHP and mysql

The `mysqli_num_rows()` function is exclusively used with `SELECT` query methods, whereas the `mysqli_affected_rows()` function returns the number of rows affected by the previous SQL statement across the entire database; this function is primarily used with `INSERT`, `UPDATE`, and `DELETE` operations.
👁 145

Recommended reading

Fresh Fruit and Vegetable Online Store Website Template – 11844 | 0552

Fresh Fruit and Vegetable Online Store Website Template – 11844 | 0552 Practical Collection Yiyou template

An EyouCMS website template designed specifically for fresh fruit and vegetable e-commerce platforms. Its fresh and natural design effectively showcases fresh fruit products, promotional campaigns, delivery services, and online purchasing options. This template helps businesses establish online shopping platforms for their fresh produce e-commerce operations and expand their sales channels. Template Display | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for EyouCMS | EyouCMS (E...
👁 38
Job Recruitment Website Template 11904 0553

Job Recruitment Website Template 11904 0553 Practical Collection Yiyou template

This EyouCMS professional template is ideal for job recruitment and talent recruitment websites. Its professional design style enables effective display of job openings, resumes, corporate directories, and talent-related services. It helps recruitment websites establish an online talent exchange platform. Template Preview | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for EyouCMS | EyouCMS (EyouC...
👁 60
Electronic Products Company Website Template – 11879 0554

Electronic Products Company Website Template – 11879 0554 Practical Collection Yiyou template

An EyouCMS website template designed specifically for electronics companies. Its modern, tech-driven design is ideal for showcasing electronic products, corporate brands, technical solutions, and product centers. This template helps electronics businesses showcase their brands online and attract industry-specific clients. Template Overview | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for EyouCMS | EyouCMS (Eyou...
👁 45
Resource website typecho001 template

Resource website typecho001 template Program Notes Typecho

typecho001 template template please do not modify the folder name of this template. The folder name is: typecho001 1.4 Fix the js output problem on the article page 1.3 Fix the error prompt when the plug-in is not installed Optimize the list page code output 1.2 Fix the comment function and add a custom homepage title 1.1 Fix the comment reply asymmetry function Add a separate title setting function on the homepage Add the website favicon.ico icon Add one...
👁 198
Knowledge-based paid video course website template – 28652 | 0555

Knowledge-based paid video course website template – 28652 | 0555 Practical Collection Yiyou template

This professional EyouCMS template is ideal for knowledge-based paid services and video course purchases. Its knowledge-centric design enables effective display of video courses, paid articles, membership plans, and purchase workflows, helping content creators build online knowledge-based payment platforms. Template Demo | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for EyouCMS | EyouCMS (Ey...
👁 60
Modification of typecho paging style

Modification of typecho paging style Program Notes Typecho

Sir, times have changed! Typecho is currently the most perfect solution, because Baidu can only see the code of fixed thinking. The actual generated HTML code is breathtakingly clean and fully customized, including adding classes to the li element, adding classes to the a element, adding classes to the previous page and next page, and removing the li tags that come with typecho to express more. I can even add some text to the content inside...
👁 516