PHP web Development, about the ' article List page display ' question?

Source: Internet
Author: User
Tags php web development

Generally display the article list, is to an article in the database to take out a strip of records, and then the title, summary and other information cycle display, now my problem is some articles have pictures, some articles do not have pictures, how to have pictures of the pictures in the article out to preview it, like Baidu Bar.

Generally in the publication of the article, is to upload images to the site directory, and then return to the image address, submitted when the picture address saved to the database. Now in the ' Article List page ' Such display situation, is through the regular to determine whether there is no picture link, or to the current data table to add a column to represent the number of pictures of the field, plus the field how to add? Or is it a different way?

Do not know I understand right, did not develop the site, is completely blind to see some source code.

Reply content:

Generally display the article list, is to an article in the database to take out a strip of records, and then the title, summary and other information cycle display, now my problem is some articles have pictures, some articles do not have pictures, how to have pictures of the pictures in the article out to preview it, like Baidu Bar.

Generally in the publication of the article, is to upload images to the site directory, and then return to the image address, submitted when the picture address saved to the database. Now in the ' Article List page ' Such display situation, is through the regular to determine whether there is no picture link, or to the current data table to add a column to represent the number of pictures of the field, plus the field how to add? Or is it a different way?

Do not know I understand right, did not develop the site, is completely blind to see some source code.

1. You can set a field in the database to feature_img display, there is a display, no will not show the scatter

2. Use a regular match in the HTML src

//@$content:string,如果是使用所见即所得文本编辑器,这个就是你的post过来的文章内容//@matches:stringpreg_match_all('//i',$content,$matches);$feature_img = $matches[0]//取得图片的url,存入数据库//echo $matches[0];

Save the picture to a different field.

If it is uploaded separately, you can add a field, if it is written with a rich text editor, you can also configure the file is uploaded to where, it is necessary to put a field or a separate field to see you are not too much trouble

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.