Jump to content

[SOLVED] viewing only a certain amount of characters from a mysql table


justAnoob

Recommended Posts

i have info stored in a mysql table that is displayed into a table on my site. one of the rows in the table is a description that could be a whole lot of text. The code below displays the data from the mysql table but what I'm looking to do is only display about 50 or so characters, and then have a text link after the text saying "Read More". Where should I start going about this???

Link to comment
Share on other sites

sorry, ,,, here is the code i have so far.

<?php
$uid = $_GET['user_id'];
$sql = mysql_query("SELECT imgpath, item_name, description, in_return, user_id FROM $table5 ORDER BY id DESC LIMIT 0, 4");
echo "<table border='0' CELLPADDING=5 STYLE='font-size:16px'>";
echo "<table border=1> <tr> <td><H3>Image </h3></td> <td><H3>Item&nbspName</H3></td> <td><H3>Description</H3></td><td><H3>Seeking</H3></td></tr>";
while ($row = mysql_fetch_array($sql))
{
   echo "<tr><td align='center'>";
   echo '<img src="' . $row['imgpath'] . '" width="125" alt="" />';
   echo "</td><td align='center'>";
   echo $row['item_name'];
   echo "</td><td align='center'>";
   echo $row['description'];
   echo "</td><td align='center'>";
   echo $row['in_return'];
   echo "</td></tr>";
}
echo "</table>";
?>

Link to comment
Share on other sites

Maq, he thort we all got Cristal balls, my ball broke lol.

 

 

echo "".substr($row['description'],0,50),"";

 

example.

<?php

$row['description']="i love php, but i find it very hard, but i like the check, at the end of the week!";

echo "".substr($row['description'],0,50),"";

?>

Link to comment
Share on other sites

then i would just add the href at the end of that correct???,,, for the Read More link.

 

Yes, but we don't know how you link the articles/items, w/e it is, so it's impossible to tell you what the URL should look like.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.