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

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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