Jump to content


Photo

Displaying Name


  • Please log in to reply
3 replies to this topic

#1 kevin_it

kevin_it
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 01 September 2006 - 01:26 PM

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 echo $_SESSION['MM_Username'] 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

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 01 September 2006 - 04:04 PM

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:
$sql = "SELECT firstname, lastname FROM user_table WHERE firstname='" . $_SESSION['MM_Username'] . "'";
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:
$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>,";
}

Thats it!

#3 kevin_it

kevin_it
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 05 September 2006 - 01:52 PM

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

#4 kevin_it

kevin_it
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 06 September 2006 - 01:37 AM

this worked perfectly. thanks.



Kevin




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users