TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
Stats
  • Total Posts: 196,004
  • Total Topics: 21,330
  • Online today: 123
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 123
  • Total: 123

help in intro display (php) block

Started by fangweile, May 08, 2012, 09:24:36 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

fangweile

global $smcFunc, $scripturl;
$query = $smcFunc['db_query']('', '
    SELECT intro
    FROM {db_prefix}tp_articles
    WHERE useintro = {int:intro}
    AND category = {int:cat}
    ORDER BY rand()
    LIMIT 5',
array('intro' => 1, 'cat' => 4)
);
while ($row = $smcFunc['db_fetch_assoc']($query))
echo htmlspecialchars_decode($row['intro']);


Hello there,

I have used this code above  to display random article intro in a php block but it display some codes in php. I attached the screenshot.

BTW, the articles are written as php article.

Thanks in advance


IchBin

What does your intro column contain for those intro's? Is it on all intro's that it displays?

fangweile

I used this code to display php intro in my article

echo <<<EOT
<!--Start Intro-->
<center>
<table><tr><td class="images">
<span class="upperframe"><span></span></span>
<div class="roundframe"><div class="blockbody" style="overflow: auto;height: 100%;">
<!--Intro Edit-->
<a href="http://www.allkoreans.net/index.php?page=new-gisaeng-story-korean-drama-2011"><img width="150" src="http://www.allkoreans.net/gallery/albums/Korean-Dramas/New-Gisaeng-Story/thumb_New-Gisaeng-Story-03.jpg" alt="New Gisaeng Story" title="New Gisaeng Story"/>
</a><br/>
<center><strong><a href="http://www.allkoreans.net/index.php?page=new-gisaeng-story-korean-drama-2011">New Gisaeng Story</a></strong></center>
<!--Intro Edit-->
</div></div>
<span class="lowerframe"><span></span></span>
</td></tr>
</table>
</center>
<!--End Intro-->
EOT;
?>


It display just right when viewing the category
http://www.allkoreans.net/index.php?cat=4
But when using it to display in a block is just showed the attached file

G6Cad

Remove ?> from the code in the end and test in PHP block, the php tags are not needed in the block as the php block already hold the start and end php tags

fangweile

Thank G6 for you reply,

I have remove ?> as you suggested but still it display the same thing.

IchBin

There's nothing in the code you posted that indicates it needs to be in a PHP block. It's all HTML so why not use an HTML/javascript block?

Eitherway, you can make it work if you don't use the EOT syntax. Just use a regular echo statement instead.

echo 'all your code goes inbetween the single quotes and ends with a semi-colon';

fangweile

This is code I used in php block to display random articles intros.

global $smcFunc, $scripturl;
$query = $smcFunc['db_query']('', '
    SELECT intro
    FROM {db_prefix}tp_articles
    WHERE useintro = {int:intro}
    AND category = {int:cat}
    ORDER BY rand()
    LIMIT 5',
array('intro' => 1, 'cat' => 4)
);
while ($row = $smcFunc['db_fetch_assoc']($query))
echo htmlspecialchars_decode($row['intro']);



And below is the code I used in Article Intro
echo <<<EOT
<!--Start Intro-->
<center>
<table><tr><td class="images">
<span class="upperframe"><span></span></span>
<div class="roundframe"><div class="blockbody" style="overflow: auto;height: 100%;">
<!--Intro Edit-->
<a href="http://www.allkoreans.net/index.php?page=new-gisaeng-story-korean-drama-2011"><img width="150" src="http://www.allkoreans.net/gallery/albums/Korean-Dramas/New-Gisaeng-Story/thumb_New-Gisaeng-Story-03.jpg" alt="New Gisaeng Story" title="New Gisaeng Story"/>
</a><br/>
<center><strong><a href="http://www.allkoreans.net/index.php?page=new-gisaeng-story-korean-drama-2011">New Gisaeng Story</a></strong></center>
<!--Intro Edit-->
</div></div>
<span class="lowerframe"><span></span></span>
</td></tr>
</table>
</center>
<!--End Intro-->
EOT;
?>


I have tried your suggestion
Quote
echo 'all your code goes in between the single quotes and ends with a semi-colon';
and it works however its still display the php tags I used.
take a look at this url
http://www.allkoreans.net/index.php?cat=4

IchBin

There's no need for any PHP tags. You only need the echo as I showed you.

fangweile


G6Cad

#9
echo '
<!--Start Intro-->
<center>
<table><tr><td class="images">
<span class="upperframe"><span></span></span>
<div class="roundframe"><div class="blockbody" style="overflow: auto;height: 100%;">
<!--Intro Edit-->
<a href="http://www.allkoreans.net/index.php?page=new-gisaeng-story-korean-drama-2011"><img width="150" src="http://www.allkoreans.net/gallery/albums/Korean-Dramas/New-Gisaeng-Story/thumb_New-Gisaeng-Story-03.jpg" alt="New Gisaeng Story" title="New Gisaeng Story"/>
</a><br/>
<center><strong><a href="http://www.allkoreans.net/index.php?page=new-gisaeng-story-korean-drama-2011">New Gisaeng Story</a></strong></center>
<!--Intro Edit-->
</div></div>
<span class="lowerframe"><span></span></span>
</td></tr>
</table>
</center>
<!--End Intro-->';


try this code

This website is proudly hosted on Crocweb Cloud Website Hosting.