Home Backend Development PHP Tutorial dedecms batch extracts the code of the first picture as the thumbnail (article + software)_PHP tutorial

dedecms batch extracts the code of the first picture as the thumbnail (article + software)_PHP tutorial

Jul 21, 2016 pm 03:43 PM
dedecms under code specific picture accomplish batch extract article of software

The specific implementation code is as follows: A brief explanation will be given below.

Copy code The code is as follows:

/*
1. Configure your Database connection
2. Note that the prefix of the data table name defaults to dede_
3. Be sure to back up your database first or back up the dede_archives table. I am not responsible for any losses.
*/
//Database Connection settings
$ip = "localhost"; //Address
$user = "jb51"; //Username
$pw = "www.jb51.net"; //Password
$ db = "jb51"; //Table name
$conn=mysql_connect ($ip,$user,$pw);
mysql_select_db($db);
mysql_query("set names gbk"); / /Set encoding to GBK

//Start! Get body data
function body($id){
$exec="select * from dede_addonsoft where aid = '".$id."' ";
$result=mysql_query($exec);
$rs=mysql_fetch_object($result);
$id = $rs->introduce;
return $id =$id;
}
//End! Get body data

//Start! Extract the first image address in the variable
function bodyimg($obj) {

if(isset ($obj)){
if ( preg_match( "", $obj, $regs ) ) { //Use Regularly obtain the first image address
return $obj = $regs[1] ;
} else {
echo "Erro: No image address!
";
return $obj = 1 ;
}
}


}
//End! Extract the first image address in the variable

//Start modifying rchives and insert the obtained Image address
function changearchives($pic,$id) {
$sql="UPDATE `dede_archives`
SET `litpic` = '".$pic."'
WHERE `id` = '".$id."'";
$result=mysql_query($sql);
if($result==1) echo "Data modification successful!
";
else echo "Failed to modify data!
";
}
//End modifying rchives, insert the obtained image address

//Display data Table content
$exec="select * from dede_archives where typeid in(494,495,496,497,498,499,500,501,502,503,504,374,375,376,377,378,379,488) and litpic = ''"; //channel='1' means the article channel can also use typeid=''
$result=mysql_query ($exec); //Specify the column ID but it can only be the ID of the smallest category, litpic = '' means the thumbnail address is empty
while($rs=mysql_fetch_object($result))
{

$id = $rs->ID;
echo $id." ";
$body = body($id); //Call function to get body content
$pic = bodyimg ($body); //Call the function to get the address of the first picture in the body
if ($pic<>1){
changearchives($pic,$id); //Call the function to insert the obtained Address
}
}
mysql_close($conn);
?>

I just learned PHP and the above code was pieced together. Beginners can also take a look at detailed comments.

Because the above code cannot automatically obtain the next-level directory, it is more manual to add the directory id. Commonly used statements are
$exec="select *. from dede_archives where typeid in(1,2,3) and litpic = ''"; //channel='1' That is, the article channel can also use typeid=''
The above code is to get the typeid as 1 and 2 and 3 data.
If you want to modify an id, you can use the following statement
$exec="select * from dede_archives where typeid='1' and litpic = ''";
If it is a channel, you can use it.
$exec="select * from dede_archives where channel='1' and litpic = ''";
Be sure to back up first, otherwise don't test it casually. Note that it is the version of dedecms5.1, other versions Should also adapt. Multiple tests (under the premise of backup.)

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/320736.htmlTechArticleThe specific implementation code is as follows: A brief explanation will be given below. Copy the code. The code is as follows: ?php /* 1. Configure your database connection 2. Pay attention to the prefix of the data table name. The default is dede_ 3....
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to solve the problem of automatically saving pictures when publishing on Xiaohongshu? Where is the automatically saved image when posting? How to solve the problem of automatically saving pictures when publishing on Xiaohongshu? Where is the automatically saved image when posting? Mar 22, 2024 am 08:06 AM

With the continuous development of social media, Xiaohongshu has become a platform for more and more young people to share their lives and discover beautiful things. Many users are troubled by auto-save issues when posting images. So, how to solve this problem? 1. How to solve the problem of automatically saving pictures when publishing on Xiaohongshu? 1. Clear the cache First, we can try to clear the cache data of Xiaohongshu. The steps are as follows: (1) Open Xiaohongshu and click the &quot;My&quot; button in the lower right corner; (2) On the personal center page, find &quot;Settings&quot; and click it; (3) Scroll down and find the &quot;Clear Cache&quot; option. Click OK. After clearing the cache, re-enter Xiaohongshu and try to post pictures to see if the automatic saving problem is solved. 2. Update the Xiaohongshu version to ensure that your Xiaohongshu

How to post pictures in TikTok comments? Where is the entrance to the pictures in the comment area? How to post pictures in TikTok comments? Where is the entrance to the pictures in the comment area? Mar 21, 2024 pm 09:12 PM

With the popularity of Douyin short videos, user interactions in the comment area have become more colorful. Some users wish to share images in comments to better express their opinions or emotions. So, how to post pictures in TikTok comments? This article will answer this question in detail and provide you with some related tips and precautions. 1. How to post pictures in Douyin comments? 1. Open Douyin: First, you need to open Douyin APP and log in to your account. 2. Find the comment area: When browsing or posting a short video, find the place where you want to comment and click the &quot;Comment&quot; button. 3. Enter your comment content: Enter your comment content in the comment area. 4. Choose to send a picture: In the interface for entering comment content, you will see a &quot;picture&quot; button or a &quot;+&quot; button, click

How to make ppt pictures appear one by one How to make ppt pictures appear one by one Mar 25, 2024 pm 04:00 PM

In PowerPoint, it is a common technique to display pictures one by one, which can be achieved by setting animation effects. This guide details the steps to implement this technique, including basic setup, image insertion, adding animation, and adjusting animation order and timing. Additionally, advanced settings and adjustments are provided, such as using triggers, adjusting animation speed and order, and previewing animation effects. By following these steps and tips, users can easily set up pictures to appear one after another in PowerPoint, thereby enhancing the visual impact of the presentation and grabbing the attention of the audience.

How to implement dual WeChat login on Huawei mobile phones? How to implement dual WeChat login on Huawei mobile phones? Mar 24, 2024 am 11:27 AM

How to implement dual WeChat login on Huawei mobile phones? With the rise of social media, WeChat has become one of the indispensable communication tools in people's daily lives. However, many people may encounter a problem: logging into multiple WeChat accounts at the same time on the same mobile phone. For Huawei mobile phone users, it is not difficult to achieve dual WeChat login. This article will introduce how to achieve dual WeChat login on Huawei mobile phones. First of all, the EMUI system that comes with Huawei mobile phones provides a very convenient function - dual application opening. Through the application dual opening function, users can simultaneously

How to arrange two pictures side by side in wps document How to arrange two pictures side by side in wps document Mar 20, 2024 pm 04:00 PM

When using WPS office software, we found that not only one form is used, tables and pictures can be added to the text, pictures can also be added to the table, etc. These are all used together to make the content of the entire document look richer. , if you need to insert two pictures into the document and they need to be arranged side by side. Our next course can solve this problem: how to place two pictures side by side in a wps document. 1. First, you need to open the WPS software and find the picture you want to adjust. Left-click the picture and a menu bar will pop up, select &quot;Page Layout&quot;. 2. Select &quot;Tight wrapping&quot; in text wrapping. 3. After all the pictures you need are confirmed to be set to &quot;Tight text wrapping&quot;, you can drag the pictures to the appropriate position and click on the first picture.

PHP Programming Guide: Methods to Implement Fibonacci Sequence PHP Programming Guide: Methods to Implement Fibonacci Sequence Mar 20, 2024 pm 04:54 PM

The programming language PHP is a powerful tool for web development, capable of supporting a variety of different programming logics and algorithms. Among them, implementing the Fibonacci sequence is a common and classic programming problem. In this article, we will introduce how to use the PHP programming language to implement the Fibonacci sequence, and attach specific code examples. The Fibonacci sequence is a mathematical sequence defined as follows: the first and second elements of the sequence are 1, and starting from the third element, the value of each element is equal to the sum of the previous two elements. The first few elements of the sequence

How to implement the WeChat clone function on Huawei mobile phones How to implement the WeChat clone function on Huawei mobile phones Mar 24, 2024 pm 06:03 PM

How to implement the WeChat clone function on Huawei mobile phones With the popularity of social software and people's increasing emphasis on privacy and security, the WeChat clone function has gradually become the focus of people's attention. The WeChat clone function can help users log in to multiple WeChat accounts on the same mobile phone at the same time, making it easier to manage and use. It is not difficult to implement the WeChat clone function on Huawei mobile phones. You only need to follow the following steps. Step 1: Make sure that the mobile phone system version and WeChat version meet the requirements. First, make sure that your Huawei mobile phone system version has been updated to the latest version, as well as the WeChat App.

How to use Copilot to generate code How to use Copilot to generate code Mar 23, 2024 am 10:41 AM

As a programmer, I get excited about tools that simplify the coding experience. With the help of artificial intelligence tools, we can generate demo code and make necessary modifications as per the requirement. The newly introduced Copilot tool in Visual Studio Code allows us to create AI-generated code with natural language chat interactions. By explaining functionality, we can better understand the meaning of existing code. How to use Copilot to generate code? To get started, we first need to get the latest PowerPlatformTools extension. To achieve this, you need to go to the extension page, search for &quot;PowerPlatformTool&quot; and click the Install button

See all articles