digitalgod Posted April 4, 2006 Share Posted April 4, 2006 Hey guys,I've made myself a image upload script that limits each users to a maximum of 10 images. What I'm trying to do is have the names of those images written in a table.Now I'm not sure what's the best way to make a table for this. What I've done is I added 21 fields in my users table, 1 for main_thumb and the rest for img1, img2, etc status1,status2 etcthe status fields are for whether the admin approved or not the images.My problem is that when a user uploads an image I want the script to be able to find out where to insert the name so if the user already uploaded 1 image and is uploading a second one the script will see that that the img1 field has something in it but the img2 field is empty so it will insert the name in img2 and insert "Pending Approval" in status2.I hope I made myself clear!Any help would be greatly appreciated Quote Link to comment https://forums.phpfreaks.com/topic/6572-inserting-data-in-a-field-only-if-that-field-is-empty/ Share on other sites More sharing options...
AV1611 Posted April 4, 2006 Share Posted April 4, 2006 I have a program with a simular issue, only it's with adding new part numbers to the system:Here is how I did it:I great big script!first run a query starting with the lowest field number and do a series of clauses until I find an "empty". if there is not "empty", then they get an error message...You just have to think very linear to figure it out, but it's not that hard. Quote Link to comment https://forums.phpfreaks.com/topic/6572-inserting-data-in-a-field-only-if-that-field-is-empty/#findComment-23898 Share on other sites More sharing options...
digitalgod Posted April 4, 2006 Author Share Posted April 4, 2006 [!--quoteo(post=361649:date=Apr 4 2006, 02:32 PM:name=AV1611)--][div class=\'quotetop\']QUOTE(AV1611 @ Apr 4 2006, 02:32 PM) [snapback]361649[/snapback][/div][div class=\'quotemain\'][!--quotec--]I have a program with a simular issue, only it's with adding new part numbers to the system:Here is how I did it:I great big script!first run a query starting with the lowest field number and do a series of clauses until I find an "empty". if there is not "empty", then they get an error message...You just have to think very linear to figure it out, but it's not that hard.[/quote]thanks for your reply AV1611 but I think I have it all wrong.I think it would be much easier if I created a table for the images something likeid || username || image_name || statusthat way there won't be as much clutter as before plus there won't be a problem when people start deleting and adding new pics.Now my question is would a table like that be any good or will it slow things down since the script might have to do a lot of searching to find the images that belongs to a user. And what will happen if a user deletes an image and the whole row is deleted, will the id change by itself or will it remain the same?example:id || username || image_name || status342 || AV1611 || 123.jpg || Approved343 || digitalgod || 456.jpg || Approvedand you decide to delete your 123.jpg what will happen if I remove the whole row? Quote Link to comment https://forums.phpfreaks.com/topic/6572-inserting-data-in-a-field-only-if-that-field-is-empty/#findComment-23905 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.