Jump to content

Single row per user


Recommended Posts

Have a simple insert into db table as:$query = "INSERT INTO imgTest (user_id, img1, active) VALUES ('$user_id', '$img1', 'n')";This query creates each time a row the query is executed. I would like to have only one single row per user (later on I will add more fields to table) and if there is already an entry for this particular column to update column with file name and move new file into image folder as usual deleting old file.I move the file as:

if(move_uploaded_file($_FILES['img1']['tmp_name'], "{$images}/{$img1}")) {			echo '<p>the file has been uploaded ok</p>';			} else {			echo '<p>the file upload did not work</p>';			}

Has anyone done such a thing and can share the experience?Kurt

Link to post
Share on other sites

Umm... its better practice to create a new relational table that stores the image information in relation to the user's id as you are doing now. What is wrong with your current system?

Link to post
Share on other sites
Umm... its better practice to create a new relational table that stores the image information in relation to the user's id as you are doing now. What is wrong with your current system?
I use a single table as I only want user to upload the max number of files and as I said if they upload a new file into one column to update the relevant column only. With the current system the user can use upload file and upload 100 files from same input. This means not only that there are a lot of rows for that user in table, but also that our server gets cluttered with unnecessary files...Kurt
Link to post
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...