Results 1 to 2 of 2

Thread: help with displaying data

  1. #1
    Join Date
    Mar 2007
    Posts
    79
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default help with displaying data

    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> ";




    ?>

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •