PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
[quote="pgolovko"]Hmmm, I'm a bit confused. How would I apply the above code into "while" loop here?
// CREATE AN EMPTY CONTAINER
$my_container = array();
// TEST SUCCESS
if (mysql_num_rows($result))
{
// LOOP
while ($row = mysql_fetch_array($result))
{
// MEASURE THIS FIRST-- REDUCE TO INTEGER MATH
$tmax = strlen($row['title']);
$dmax = strlen($row['description']);
// NOW TEST IT
$row['title'] = ($tmax<100)?$row['title'] :substr($row['title'], 0, 97)."...";
$row['description'] = ($dmax<500)?$row['description'] :substr($row['description'], 0, 497)."...";
// NOW SAVE IT
$my_container[] = $row;
}
}
// YOU NEED TO COMMENT YOUR CODE
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]