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