2013-04-28 5 views
1

나는 phpbb 포럼이 있고 나는 나의 웹 사이트에 최신 3 개의 게시물을 보여주고 싶다. 내가 DB에 연결할 수 있고 원하는 것을 검색 할 수 있지만 게시물에서 img가 아닙니다. 포스트 콘텐츠는 게시물의 모습을 내가 할 때 물방울로 저장됩니다. "안녕하세요이 테스트 게시물입니다 파일의웹 사이트에 blob 파일 (텍스트 + img)을 표시하십시오. phpbb 데이터베이스에서

[img]http://www.petfinder.com/wp-content/uploads/2012/11/101418789-cat-panleukopenia-fact-sheet-632x475.jpg[/img]

끝."

포럼에서 텍스트와 이미지를 볼 수 있습니다.

(Hello this is a test post. [img:3vv18at0]http://www.petfinder.com/wp-content/uploads/2012/11/101418789-cat-panleukopenia-fact-sheet-632x475.jpg[/img:3vv18at0]End of the file.)

가 텍스트로 entery 게시물을 표시, 나는 그들의 장소에서 포럼, 텍스트와 이미지에서와 같이 게시물을보고 싶다 : 나는 내 웹 사이트에 게시물을 보여줄 때 그것은 것 같습니다.
<?php 
    $conexion = mysql_connect("localhost","MYUSER","MYPASS"); 
    $nPost = "0,3"; 
    //DB a la que me conecto  
    mysql_select_db("DATABASE", $conexion) OR die("No se puede establecer la conexión a MySQL"); 
    $consulta1 = "SELECT * FROM phpbb_topics WHERE forum_id = '4' ORDER BY topic_id DESC LIMIT $nPost"; 
    $resultado1 = mysql_query($consulta1); 
    $consulta2 = "SELECT * FROM phpbb_posts WHERE forum_id = '4' ORDER BY topic_id DESC LIMIT $nPost"; 
    $resultado2 = mysql_query($consulta2); 

    while ($row = mysql_fetch_array($resultado1)) { 

    $datosPost = mysql_fetch_array($resultado2); 

    $id = "$row[topic_id]"; 
    $titulo = "$row[topic_title]"; 
    $respuestas = "$row[topic_replies]"; 
    $by = "$row[topic_first_poster_name]"; 
      $text = "$datosPost[post_text]"; 
    ///////////////////EDIT AND WORKING////////////////// 
      $b = preg_replace('#\[img:(.*?)\](.*?)\[/img:(.*?)\]#s', '<br><img src="$2"/><br> ', $text); 
    $c = preg_replace('#\((.*?)\)#s', '$1', $b);   
    $text = $c; 
      ////////////////////////THANKS TO damienkeitel////////////// 

     echo"<a href='http://www.compraclientes.com/foro/viewtopic.php?f=4&t=$id'><div class='postEntry'><div class='postHeader'><div class='postTitle'>$titulo</div><div class='postOwner'>(By $by)</div> <div class='postReplies'>($respuestas Respuestas)</div></div><div class='postText'>($text)</div></div></a>"; 
     } 
    mysql_close($conexion);   
    ?> 

, 당신에게

+1

'mysql_로 *'되지 않는 한, 바로이 시간 –

+0

를 얻을 수있는 사람이 당신의 BLOB 필드입니다 mysqli' 또는'PDO''로 마이그레이션하십시오? 블롭은 이미지의 바이너리를 포함합니다. 해당 필드의 데이터를 이미지 소스에 넣으면됩니다. –

+0

$ text = "$ dataPost [post_text]"; 이 하나의 BLOB 필드입니다. – user2329440

답변

0
$a = "(Hello this is a test post. [img:3vv18at0]http://www.petfinder.com/wp-content/uploads/2012/11/101418789-cat-panleukopenia-fact-sheet-632x475.jpg[/img:3vv18at0]End of the file.)"; 
$b = preg_replace('#\[img:(.*?)\](.*?)\[/img:(.*?)\]#s', '<br><img src="$2"/><br> ', $a); 

$c = preg_replace('#\((.*?)\)#s', '$1', $b); 
echo $c; 

http://www.damienkeitel.com/pr.php < - 데모

+0

모두에게 감사드립니다! – user2329440

0

내가 약간 수정 내 이전의 대답 중 하나 믿고 대단히 감사합니다 당신이 필요로하는 정보를 제공 할 수 있습니다 :

내가 사용하고있는 코드입니다.

Display the 5 most recent posts on an external page

귀하의 질문에 짧은 대답은 코드의 덩어리입니다. 이렇게하면 데이터의 다양한 측면이 정리됩니다. 나는 이전의 대답에 언급 된 바와 같이

 $topic_title  = $posts_row['topic_title']; 
    $post_author  = get_username_string('full', $posts_row['poster_id'], $posts_row['username'], $posts_row['user_colour']); 
    $post_date   = $user->format_date($posts_row['post_time']); 
    $post_link  = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "p=" . $posts_row['post_id'] . "#p" . $posts_row['post_id']); 

    $post_text = nl2br($posts_row['post_text']); 

    $bbcode = new bbcode(base64_encode($bbcode_bitfield));   
    $bbcode->bbcode_second_pass($post_text, $posts_row['bbcode_uid'], $posts_row['bbcode_bitfield']); 

    $post_text = smiley_text($post_text); 

은, 그 코드는 Example 4 PHPBB 위키를 기반으로합니다.