ATutor

Learning Management Tools







Pages:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15


Display first name with last initial


  • 2009-06-24 15:11:24

    Display first name with last initial

    Hello. I have 1.6.2 installed and I am working with formatting the link to my Elluminate classroom. I want to pass the username into the URL of the Elluminate link. However, I would like it to be student first name and last initial. I can do that one of two ways....

    1. Get ATutor to display the username as the first name and last initial (currently not an option in the System Preferences in admin). Then use something like

    [php] echo get_display_name($_SESSION['member_id']);[/php]


    2. Manually build the first name, last initial part in the index.php file of the Elluminate module. So far I have

    [php]
    $sql = "SELECT last_name FROM ".TABLE_PREFIX."members WHERE member_id='$_SESSION[member_id]'";
    $result = mysql_query($sql,$db);
    if ($row = mysql_fetch_assoc($result)) {

    $last_name = $row['last_name'];
    }

    php echo ($last_name['last_name']);
    [/php]

    This returns the last initial. Unsure as to why it only returns the last initial instead of the entire last name. If I do something similar for the first name I will only get the first initial.


    Any ideas on which would be better/easier?

    Thank you.

  • 2009-06-24 15:15:15

    Re: Display first name with last initial

    Oops.... never mind the double "<?php" and "?>" tags. I didn't know it would put those in twice when I wrapped my code in the php tags on this forum.

  • 2009-06-24 15:46:41

    Re: Display first name with last initial

    #1 one would be the more efficient way, but if you are not the ATutor admin, there's no guarantee of the display name format being first name second name.

    #2 would be more fool proof, pulling the first and last name directly from the db.

  • 2009-06-24 15:53:00

    Re: Display first name with last initial

    Thanks for responding Greg.

    Do you have any insight on #2? Why would I just get the first initial of the name? How can I get the full last name or full first name?

    By the way, I am the ATutor admin.

    Thanks!

  • 2009-06-24 17:46:34

    Re: Display first name with last initial

    No idea why only the first initial. Your sql looks fine.

    You've confirmed the full name is actually in the database?

  • 2009-06-24 18:07:50

    Re: Display first name with last initial

    Yes. Full names in the database........

    Some kind of php.ini setting perhaps?