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???

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

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

?>

  Quote

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.