kevin_it Posted September 1, 2006 Share Posted September 1, 2006 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.KevinKevin Quote Link to comment https://forums.phpfreaks.com/topic/19365-displaying-name/ Share on other sites More sharing options...
wildteen88 Posted September 1, 2006 Share Posted September 1, 2006 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 matchif(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! Quote Link to comment https://forums.phpfreaks.com/topic/19365-displaying-name/#findComment-84100 Share on other sites More sharing options...
kevin_it Posted September 5, 2006 Author Share Posted September 5, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/19365-displaying-name/#findComment-86362 Share on other sites More sharing options...
kevin_it Posted September 6, 2006 Author Share Posted September 6, 2006 this worked perfectly. thanks.Kevin Quote Link to comment https://forums.phpfreaks.com/topic/19365-displaying-name/#findComment-86841 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.