MySql record

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Hunnam
Forum Newbie
Posts: 4
Joined: Thu Jul 05, 2007 3:50 am

MySql record

Post 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.
User avatar
Gente
Forum Contributor
Posts: 252
Joined: Wed Jun 13, 2007 9:43 am
Location: Ukraine, Kharkov
Contact:

Post by Gente »

Use

Code: Select all

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

Code: Select all

echo $row['your_var'];
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post 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`;
Hunnam
Forum Newbie
Posts: 4
Joined: Thu Jul 05, 2007 3:50 am

Post by Hunnam »

Thank you for your replies, I went with the code change and it works a treat.
Post Reply