true2self Posted October 20, 2008 Share Posted October 20, 2008 Hi All, I'm sure this is a newbie question, so please bear with me. I'm displaying the SSN from a database, but I only would like the last four digits shown. Can someone please assist? Here is the echo code $user = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $auser->id . '&course=' . $course->id . '">' . fullname($auser) . "<br /> " . $auser->ssn . '</a>'; This is the MySQL code $select_ssn = 'SELECT u.id, u.ssn FROM '.$CFG->prefix.'site u order by u.displayorder'; Link to comment https://forums.phpfreaks.com/topic/129252-displays-a-certain-amount-of-numbers/ Share on other sites More sharing options...
rhodesa Posted October 20, 2008 Share Posted October 20, 2008 replace $auser->ssn with substr($auser->ssn,-4) Link to comment https://forums.phpfreaks.com/topic/129252-displays-a-certain-amount-of-numbers/#findComment-670110 Share on other sites More sharing options...
true2self Posted October 20, 2008 Author Share Posted October 20, 2008 cool. Thanks!!! Link to comment https://forums.phpfreaks.com/topic/129252-displays-a-certain-amount-of-numbers/#findComment-670122 Share on other sites More sharing options...
discomatt Posted October 20, 2008 Share Posted October 20, 2008 In MySQL: SELECT SUBSTRING(`ssn`, -4) FROM `table` Link to comment https://forums.phpfreaks.com/topic/129252-displays-a-certain-amount-of-numbers/#findComment-670138 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.