Forums
This topic is locked
Truncation of fields from database
Posted 15 May 2004 18:59:48
1
has voted
15 May 2004 18:59:48 James Kemp posted:
I am using Dreamweaver mx 2004 & PhpI have a results page on my website that displays text from my database etc. I want to truncate one of the text fields so that it only displays the first 50 characters. I've heard that it can be done in MYSQL as follows:
SELECT LEFT(long_field, 50) AS preview FROM your_table
or alternatively in PHP as follows:
$preview = substr($whole_field, 0, 50);
My question is how to incorporate these functions into my sql queries/PHP Code:
SELECT *
FROM MyTable
WHERE MyField LIKE '%colname%'
<?php echo $row_rsRecordset['Myfield']; ?>
The preview function in sql does not seem to work well with the dreamweaver mx repeat region funtionality and just shows the first record on the database.
Replies
Replied 16 May 2004 17:17:53
16 May 2004 17:17:53 Phil Shevlin replied:
<?php echo substr($row_rsRecordset['Myfield'],0,50); ?>