Forum Moderators: coopster

Message Too Old, No Replies

Beginner, Help with short discription.

how to echo only a small amount of text from db

         

ski442

11:41 pm on Mar 30, 2008 (gmt 0)

10+ Year Member



Hey Guys.

Just having a bit of trouble getting this working. I think the code is basic and should explain itself.

<?php
virtual('/include.php');
$result =mysql_query ( "select * from products WHERE feature ='yes' order by rand() limit 6");
while ($row = mysql_fetch_array($result))
{
echo '<li>';
echo '<div id="title">' . $row ['title'] . '</div>';
echo '' . $row ['nail'] . '';
$length = 200;
$shortdiscription = substr_replace($row['discription'], "....", $length);
echo '' . $row ['$shortdiscription'] . '';
echo '<div id="featureofferprice">' . $row ['onoffer'] . '</div>';
echo '' . $row ['morelink'] . '';
echo '</li>';
}
?>
I have posted all code so you can see in which context i'm trying to use it.
Its just this part i know is wrong as it will not display anything
$length = 255;
$shortdiscription = substr_replace($row['discription'], "....", $length);
echo '' . $row ['$shortdiscription'] . '';

Can you clever people piont me in the right diretion.
I have tried altering the code but no use.
all help welcome.
Thanks in advance
Joe Ski442

IanKelley

6:18 am on Mar 31, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



This:

echo '' . $row ['$shortdiscription'] . '';

Should be:

echo $shortdiscription;

ski442

9:32 pm on Mar 31, 2008 (gmt 0)

10+ Year Member



Thanks very much Ian.

I tried all but that.
Nevermind Thanks once again.
Joe Ski442