Debt Consolidation - Watch Anime - Debt Consolidation - Kamala - Kamala Harris

PDA

View Full Version : Limited amount of text from record


save
Aug 21st 2007, 10:55 pm
How would I be able to only show say 300 characters from the description field when I retrieve records from MySQL?

$query = "SELECT id, name, price, image_url, description FROM `products` ORDER BY rand() LIMIT 4;";
database_inquiry($query, $rows);
$products = $rows;


<?=$item['description']; ?>

sea otter
Aug 21st 2007, 11:11 pm
Well...do you want mysql to limit what it returns for the description to <= 300 characters, or do you want mysql to return the entire description and do the limiting in php?

save
Aug 21st 2007, 11:40 pm
i want to do the limiting in php

sea otter
Aug 21st 2007, 11:51 pm
<?=substr($item['description'],0,300); ?>

save
Aug 21st 2007, 11:56 pm
rep added, cheers!

baris22
Nov 29th 2007, 5:28 am
Thank you very much


<?=substr($item['description'],0,300); ?>