Jump to content

Displaying Name


Recommended Posts

Ok, Dreamweaver is pissing me off. :)

I would like to display the First and Last name of the User logging in. In my table i have all the necessary columns, fields, etc ...

I think my only problem is I have no idea what variable to use to query against. I can successfully use [b]echo $_SESSION['MM_Username'][/b] and it displays the username. I don't want that. Can I use $_SESSION['MM_Username'] somehow in my query to get the firstname and lastname fields? I figure that the username would be the best way to use int he query as it is unique.

Is there a much simpler way to do this?

Thanks all.

Kevin

Kevin
Link to comment
Share on other sites

Thats your problem you get something to do something for you, and then you try do something, but you cant. You should learn to code PHP yourself rather than get DW to do it for you. Dreamweaver isnt a good editor to develope PHP scripts with.

But anyway lets crackon.

Whats the code you are using to query the database. You can use $_SESSION['MM_Username'] in the WHERE clauase of you query, For example:
[code=php:0]$sql = "SELECT firstname, lastname FROM user_table WHERE firstname='" . $_SESSION['MM_Username'] . "'";[/code]
Noter: Change where it says user_table to the correct table name which holds the firstnames and lastnames.

Now use the following to perform the query:
[code=php:0]$sql = "SELECT firstname, lastname FROM user_table WHERE firstname='" . $_SESSION['MM_Username'] . "'";
$sql_result = mysql_query($sql) or die("unable to perform the query due to an internal error: " . mysql_error());

// check that the query returned 1 result, if it did it found a match
if(mysql_num_rows($sql_result) == 1)
{
    // retrieve the first name and lastname from result
    $row = mysql_fetch_assoc($sql_result);

    // display first name and last name:
    echo "Welcome <b>" . $row['firstname'] . ' ' . $row['lastname'] . "</b>,";
}[/code]

Thats it!
Link to comment
Share on other sites

I appreciate the response and will try it and let you know.

I value your input, but my response to your comment is that I AM learning php. Unfortunately I do not have the luxury of spending tons of time on it, so therefore I turned to Dreamweaver to handle as much php as i need it to until I get a stranglehold on this.

Thanks.

Kevin
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.