PDA

View Full Version : help with displaying data



sukanya.paul
11-15-2007, 04:42 AM
hi.. i hv a table which has certain field including one column called testimonials. the testimonial can be long but i want to display only 50 characters in a page with a link to a new page whr users can read the entire testimonial.
i am not able to do that.
pls help..its very very urgent..
thanks a ton..
my code is
<?php
include("connection/connect.php");
$valid = false;
$sql="SELECT title,testimonials,userid FROM tbl_testimonials";
$query = mysql_query($sql) or die (mysql_error());
$count=mysql_num_rows($query);
if ($count>0)
$valid=true;
if ($valid)
{
echo "<table width='95%' border='2' >
<tr>
<th> </th>
<th> </th>
<th> </th>
</tr>";
while($row = mysql_fetch_array($query))
{
echo "<tr>";
echo "<td>" . $row['title'] . "</td>";
echo "</tr>";
echo "<tr>";
echo("<td>");
echo ("for ($i=0; $i<50 ; $i++");
{
echo ("<br>". $row['testimonials[$i]'] );
}
echo("</td>");echo "</tr>";
echo "<tr>";
echo("<td>");

echo("<a href='" . "read_testimonials.php" . "?userid=".$row['userid']." ' >" );

echo("<br/>" . "Read More" . "</a>");
echo("</td>");
echo "</tr>";
}
echo "</table>";
}
else
echo "<BR><center> NO TESTIMONIALS AVAILABLE.</CENTER> ";




?>

djr33
11-15-2007, 06:44 AM
substr($row['testimonials[$i]'],0,50)

That will give you the first 50 characters of the string.

Then you can link to another page, and include the $i value, to get the testimonial again. Use a get variable, like ?i=#, then use $_GET['i'] on the next page as $i, and find it.