I am trying to truncate variables from a mysql database, so when I show my display of the database in a table, it limits the characters shown.
so in my code I have an array that spits out my variables into a table,
I grab the data through, my query.
$sql="SELECT * FROM _products WHERE pending='0' AND deleted='0' ORDER BY productID ASC";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
then I have my data output in the table, so I can click edit on it, to change things.
<td><? echo $rows['productID']; ?></td>
<td><? echo $rows['pageName']; ?></td>
<td><? echo $rows['section1']; ?></td>
<td> <? echo $rows['section2']; ?></td>
<td><? echo $rows['customer']; ?></td>
I know shorthand, I'm changing my codes so there not that way..
I was going to try to use substr_replace, but thats for strings not variables??, but can I put my variable into a string, then limit it, and display the string instead of the variable in this example?
I tried a few things but got very lost.
I found the example on the main page talking about substr_replace to truncate, so that is what I'm trying to do with my section1, section2 pieces of my database table when displayed.
Example from this page
$article = "BREAKING NEWS: In ultimate irony, man bites dog.";
$summary = substr_replace($article, "...", 40); // $summary = "BREAKING NEWS: In ultimate irony, man bi..."