Jump to content

Single row per user


kurt.santo

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 comment
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 comment
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 comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...