How to call the content of two php tables

Source: Internet
Author: User
How to call the content of the two php tables? in this issue, Wei Xueman, a vocal music teacher from Hunan Satellite TV's "hundred changes and big coffee show", will appear. [Img] 115 [/img] In addition, starting from next week, every mentor will take his/her dream mentor to the team. Therefore, the dream mentor candidate will become the target of everyone's speculation, the rumored version is overwhelming. [Img] 119 [/img] Among the four final students this week, singer Wei Xueman is the most famous student. she was at [img] 165 [/img]

This is the body field in the news table. However, the image is in the pic table. The number in [img] 165 [/img] is the ID of the pic table, and the image address exists in the add Field after the corresponding ID.
Correctly display the php code of this news article.


Reply to discussion (solution)

When this text is output, replace [img] 115 [/img]
Search for and output image data by input id in pic. php

Thank you for your attention? I am not familiar with the main book.

$ S = <TXT in this issue, Wei Xueman, a vocal music teacher from Hunan Satellite TV's "hundred changes big coffee show", will appear. [Img] 115 [/img] In addition, starting from next week, every mentor will take his/her dream mentor to the team. Therefore, the dream mentor candidate will become the target of everyone's speculation, the rumored version is overwhelming. [Img] 119 [/img] Among the four students who finally appeared this week, singer Wei Xueman is the most famous student. she was in [img] 165 [/img] TXT; echo preg_replace ('/\ [img \] (\ d +) \ [\/img \]/', ', $ s );
In this issue, Wei Xueman, a vocal music teacher, will appear in Hunan Satellite TV's "hundred changes big coffee show. In addition, starting from next week, every mentor will take his/her dream mentor into the team. Therefore, the dream mentor candidate will become the target of everyone's speculation, and the rumored version will be overwhelming. Among the four students who finally appeared this week, Wei Xueman, the singer, is the most famous student.

Pic. php? Id = 165 read img/110358tp58ocjpmn8paoob.jpg

However, the image cannot be displayed.

Is the image path translated by pic. php correct?

Pic. php? Id = 165 read img/110358tp58ocjpmn8paoob.jpg

However, the image cannot be displayed.


You can either read an image from 302 to the actual image address or output the image, rather than output an address string.

#1, I said, "search for and output image data by input id in pic. php"
You agree with this solution, so you have the code in #3.
So why do you only output the image path instead of the image data?

If you only want to output the image path, convert [img] 165 [/img]
Then

echo preg_replace_callback('/\[img\](\d+)\[\/img\]/', function($r) {  return ''; }, $s);
The getpicid function is used to obtain the corresponding image path from the input id.

$ S = <TXT in this issue, Wei Xueman, a vocal music teacher from Hunan Satellite TV's "hundred changes big coffee show", will appear. [Img] 115 [/img] In addition, starting from next week, every mentor will take his/her dream mentor to the team. Therefore, the dream mentor candidate will become the target of everyone's speculation, the rumored version is overwhelming. [Img] 119 [/img] Among the four students who finally appeared this week, singer Wei Xueman is the most famous student. she was in [img] 165 [/img] TXT; $ s = preg_replace ('/\ [img \] (\ d +) \ [\/img \]/', function ($ r) {return '';}, $ s); echo $ s;


This is my pic. php code.
Error message: Parse error: syntax error. unexpected T_FUNCTION points to $ s = preg_replace ('/\ [img \] (\ d +) \ [\/img \]/', function ($ r) {this line

Is your php version too small?

The php version is 5.3

Sorry, I'm dizzy.
In the pic table, only the id and image address fields are displayed.
$ S = preg_replace ('/\ [img \] (\ d +) \ [\/img \]/', function ($ r) put pic. php is obviously not suitable.
But here, I don't know how to connect the data table or the pic. php file.

$ S = <TXT in this issue, Wei Xueman, a vocal music teacher from Hunan Satellite TV's "hundred changes big coffee show", will appear. [Img] 115 [/img] In addition, starting from next week, every mentor will take his/her dream mentor to the team. Therefore, the dream mentor candidate will become the target of everyone's speculation, the rumored version is overwhelming. [Img] 119 [/img] Among the four students who finally appeared this week, singer Wei Xueman is the most famous student. she was in [img] 165 [/img] TXT; $ s = preg_replace_callback ('/\ [img \] (\ d +) \ [\/img \]/', function ($ r) {return '';}, $ s); echo $ s; function getpicid ($ id) {return response id.'.gif ';}
In this issue, Wei Xueman, a vocal music teacher, will appear in Hunan Satellite TV's "hundred changes big coffee show. In addition, starting from next week, every mentor will take his/her dream mentor into the team. Therefore, the dream mentor candidate will become the target of everyone's speculation, and the rumored version will be overwhelming. Among the four students who finally appeared this week, Wei Xueman, the singer, is the most famous student.

In this way, there is no problem in the text,

In the pic table, only the id and image address fields are displayed.
$ S = preg_replace ('/\ [img \] (\ d +) \ [\/img \]/', function ($ r) put pic. php is obviously not suitable.
But here, I don't know how to connect the data table or the pic. php file.

You can query the image address corresponding to the id in the getpicid function.
This will fill in the text.

According to the original scheme, the query is not performed when the text is output. Reading images in the browser is performed.
After you read the image address, readifle ('image address') is used to output the image data.

Pic. php code

  
 
 


Show. php code
 
 
 

You can query the image address corresponding to the id in the getpicid function.
This will fill in the text.

According to the original scheme, the query is not performed when the text is output. Reading images in the browser is performed.
After you read the image address, readifle ('image address') is used to output the image data.



Original scheme. In pic. php, I use echo readifle ("img/359z0ycw7c3p6z39c73.jpg"). The front-end is not displayed.

Does the file exist? Is the path correct?

File and path

Does the file exist? Is the path correct?



Error message: Fatal error: Call to undefined function readifle ()

File and path



All pair

Readfile

Readfile



Warning: readfile () [function. readfile]: open_basedir restriction in effect. File (img/359z0ycw7c3p6z39c73.jpg) is not within the allowed path (s)

Do you want to declare or reference readfile first?

Warning: readfile () [function]: ReadFile. Open_basedir restriction effect. (Imgfile/359z0ycw7c3p6z39c73. JPG) is not in the allowed path)

Echo readifle ("http: // localhost/img/359z0ycw7c3p6z39c73.jpg"); pic. php reads a bunch of garbled characters, which should be image data. However, if the image is not displayed, it is a Red Cross.

Why can I still display images?

Echo readifle ("http: // localhost/img/359z0ycw7c3p6z39c73.jpg"). no error is returned.
Pic. php reads a bunch of garbled characters, which should be image data.
However, if the image is not displayed, it is a Red Cross.

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.