Current location: Hot Scripts Forums » Programming Languages » PHP » Displaying last few characters of data


Displaying last few characters of data

Reply
  #1 (permalink)  
Old 07-02-04, 10:49 AM
Reg's Avatar
Reg Reg is offline
Newbie Coder
 
Join Date: Jun 2004
Location: Abilene Christian University
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Displaying last few characters of data

I have data that is stored into mySQL. In a particular field, I have data in it that is a long number. How would I go about displaying say, the last 8 or last 6 digits of that number? Thanks.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 07-02-04, 12:06 PM
Rapid Dr3am Rapid Dr3am is offline
Community VIP
 
Join Date: Jan 2004
Location: Liverpool, England
Posts: 752
Thanks: 0
Thanked 0 Times in 0 Posts
Use LIMIT 6.
__________________
Placeholder, place signature here.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 07-02-04, 12:14 PM
Reg's Avatar
Reg Reg is offline
Newbie Coder
 
Join Date: Jun 2004
Location: Abilene Christian University
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
I'm not sure what you mean.

I'm calling the data from PHP to display to a user. But, I only want to display the last few digits. How would I use LIMIT 6?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 07-02-04, 12:29 PM
Rapid Dr3am Rapid Dr3am is offline
Community VIP
 
Join Date: Jan 2004
Location: Liverpool, England
Posts: 752
Thanks: 0
Thanked 0 Times in 0 Posts
PHP Code:

$sql "SELECT username FROM users
WHERE username <> 'Anonymous' 
ORDER BY ASC LIMIT 6; 
__________________
Placeholder, place signature here.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 07-02-04, 02:26 PM
Reg's Avatar
Reg Reg is offline
Newbie Coder
 
Join Date: Jun 2004
Location: Abilene Christian University
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
That code doesn't work. That limits my results to just 6. I'm trying to limit the amout of text in the field that is being displayed to 6.

Here's an example:

Table "A" column "A" contains -> 1234567890

I only want to display to the visitor -> 567890

How would I do this?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 07-02-04, 02:35 PM
RynO RynO is offline
Newbie Coder
 
Join Date: Sep 2003
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
substr($string, -6, 6);

---------------------------

<?PHP

$string = "1234567890";

$new_string = substr($string, -6, 6);

echo $new_string;

?>

Would display 567890.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 07-02-04, 03:42 PM
Reg's Avatar
Reg Reg is offline
Newbie Coder
 
Join Date: Jun 2004
Location: Abilene Christian University
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Thumbs up Great!

That did it. Thanks.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help displaying data Damith Windows .NET Programming 2 01-14-05 04:48 PM
Displaying data based on a field in a csv file Fladrif PHP 5 03-06-04 05:02 PM
Displaying Selected Table Data from MYSQL using ? in URL jason.lafferty PHP 4 01-21-04 11:28 AM
displaying data from a db tisza PHP 1 01-10-04 10:16 AM


All times are GMT -5. The time now is 10:32 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.