Jump to content

Transfering data to a MYSQL database


daverichris

Recommended Posts

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

Link to comment
Share on other sites

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"

 

 

 

Link to comment
Share on other sites

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

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.