kurt.santo 0 Posted May 25, 2008 Report Share Posted May 25, 2008 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 Quote Link to post Share on other sites
Synook 47 Posted May 25, 2008 Report Share Posted May 25, 2008 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? Quote Link to post Share on other sites
kurt.santo 0 Posted May 25, 2008 Author Report Share Posted May 25, 2008 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 Quote Link to post Share on other sites
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.