daverichris Posted March 30, 2011 Share Posted March 30, 2011 Hello, Sorry if I have put this in the wrong category. I have created an "edit user profile" page that can only be accessed once a user has logged in. The form works correctly and sends the data, i.e. name, email, tel number, vital stats to the MYSQL database. However, when it arrives in the database its simply lost in the "profile database" as another row. I want to include the $user name or something similar so when a another user looks up the profile it will pull that users information on to the page. Does that make sense? But how? thanks Quote Link to comment Share on other sites More sharing options...
Nudd Posted March 31, 2011 Share Posted March 31, 2011 Seeing as this post didn't directly mention AJAX, my response may be irrelevant... Do you mean that you want that profile data to still be visible on the screen after posting? Or you just want to search on usernames? Regardless of the answer to either of those, a pre-requisite of anything useful happening in a mysql table is an auto incrementing id field in your profiles table - and any other table (generally also set as your primary key). Once you have that, you can do just about anything you like. If you want to retrieve the data after insertion, use the command... mysql_insert_id() ...In a select statement to retrieve that new record. (ie: "select * from profiles where id= '" . mysql_insert_id() ."'") If you just want to find users that match a certain username in a profile search, you can use a simple select statement like "select * from profiles where username = '" . $username_search . "' order by username" Quote Link to comment Share on other sites More sharing options...
daverichris Posted March 31, 2011 Author Share Posted March 31, 2011 Hello, Thank you very much for your help, can i pick your brains with a couple more questions. A user enters the "profile" page where they will be able to see their details displayed *(I've not yet put this script together). If they wish to update their profile they may edit profile and are redirected to the "edit profile page". So as you described above i can add in the *mysql_insert_id(). However, this will give it an id, but when the user next logs in and wants to view their profile, how will the "profile" page know it needs to pull down that particular id? I just assumed that i would search the user name because that would defiantly be theirs, where as i assumed an id would automaticly increment? Forgive me, this is new to me, teaching myself on bit of a crash course. mike Quote Link to comment 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.