Page 1 of 1

MySql record

Posted: Thu Jul 05, 2007 4:00 am
by Hunnam
I tried searching on Google but do not really know how to search for it properly.

What I want to do is remove the first part of a MySql record displayed on a PHP page i.e

'file:15550000.jpg' and I want to remove the 'file:' from the result and just display the '15550000.jpg', I didnt know how to search for this in Google or this forum.

Sorry if this is a bit gobbledygook.

Posted: Thu Jul 05, 2007 4:11 am
by Gente
Use

Code: Select all

echo substr($row['your_var'], 5);
instead of

Code: Select all

echo $row['your_var'];

Posted: Thu Jul 05, 2007 5:38 am
by onion2k
I'd fix it in the SQL...

Code: Select all

SELECT `myTable`.`file_id`, 
`myTable`.`file_size`, 
`myTable`.`file_type`, 
SUBSTRING(`myTable`.`file_name`,5) AS file_name_fixed
FROM `myTable`;

Posted: Thu Jul 05, 2007 7:41 am
by Hunnam
Thank you for your replies, I went with the code change and it works a treat.