yeah… thats not constructed correctly. substr($row[‘category_Description’],0,100)
It would actually be better to shorten this description at the query level, rather than at the PHP level.
$q=mysql_query(“select cat_Id,category_Name,cat_dateTime,SUBSTRING(‘category_Description’,0,100) from category order by category_Name ASC”) or die (mysql_error());
Just a tip, STOP using multiple echo’s to do one echo’s job, STOP using double quotes and string additions for multi-field output, stop using outdated deprecated elements like FONT and attributes like bgColor which have no business even being in HTML after 1998, etc, etc…
… and good lord what are you doing with all that positioning apart from trying to make a layout that’s broken everywhere?!?
<?php
$q=mysql_query("select * from category order by category_Name ASC") or die (mysql_error());
while($row=mysql_fetch_assoc($q)) {
echo '
<tr>
<th scope="row">
<a href="admin_categories.php?cat_Id=',$row["cat_Id"],'&index=',$index,'">
',$row["category_Name"],'
</a>
</th>
<td class="description">
',substr($row['category_Description'],0,100),'
</td>
<td class="date">
',$row["cat_DateTime"],'
</td>
</tr>';
}
?>
EVERYTHING else there belonging in an external stylesheet. Sorry to say it, but you have a poster child for why I say the style attribute should be deprecated… and why double quotes for echo are rubbish… inlining the CSS like that may as well be presentational markup since you’re not leveraging caching models and missing the entire POINT of using CSS in the first place.
Hi,
If the text contains html tags, when you get the substring its posible to have opened tags, which will aaffect the page format, in this case apply strip_tags() to the substring.
To deathshadow60’s point you can echo something that is mixed with single and double quotes using heredoc syntax so something like this would work:
$html = <<<MCD
<a href='http://something.com'>something</a>
<p>$_POST["apple"]</p>
<p>And we took the "fruit and nuts" to the `picnic!`</p>
MCD;
echo $html;