Jump to content

help limiting number of characters pulled from database


RyanSF07

Recommended Posts

Hello,

 

I've got:

$query_result2 = mysql_query($sql2);
while ($row2 = mysql_fetch_array($query_result2)) {

 

listing content in a table with:

<td style=\"padding: 3px 20px 5px 3px\"><p>".$row2['assignment']."</p></td>

 

I would like to limit the number of characters of the 'assignment' to 50.

 

I tried:

row2['assignment_number'] = $assign;
if(strlen($assign)>50){
echo substr($assign, 0, 50);
}

 

and then listing it with:

<td style=\"padding: 3px 20px 5px 3px\"><p>".$assign."</p></td>

 

but that didn't work.

 

Any pointers on how to accomplish this? Thank you,

Ryan

 

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.