Page 1 of 1

database element selection HELP!!

Posted: Wed Mar 17, 2010 10:25 pm
by chivopunk
Hi guys, I'm kinda new in this whole PHP and MySQL world, and I'm kinda stuck in something. I have a database with 624 elements with 11 fields, is a nutrition table database. I programmed a search engine that allows a user to enter a word and it will list all the elements containing that word. In addition the output of this search contains checkboxes for each element found. What I want to do, and having problems doing it, is that when the user checks the desired element, it dumps it into another table so that the user can manipulate the contents of those fields without harming the original data.

I would apreciate all the help!!

Thanks.

Re: database element selection HELP!!

Posted: Thu Mar 18, 2010 1:24 am
by requinix
So what's the purpose of manipulating the data?

Anyways, create another table just like the first but with an additional field at the beginning. Called something like "sessionID" or "user" or whatever. Something that can be used to identify a user uniquely - if you're using sessions then the session ID, or if the person has to be logged in then you can use their user ID or username.

Then when it comes time to make a copy of the data, clear out everything in that copy table belonging to the current user and dump the old stuff in there - attaching the session ID/user ID/whatever along with it. Then the user can make all the changes they need by working off of (a) the stuff in that table that (b) has their ID with it.
This way you can have two people doing the same thing at once. (Yes, I know that may not be the case for you, but it's still a good idea to pretend it might happen.)

Re: database element selection HELP!!

Posted: Thu Mar 18, 2010 9:56 am
by chivopunk
the purpose for manipulating the data is to create a program, that alllows a user, in this case myself, to assemble a diet. For example: I want to add chicken to the diet, I do a search for all the elements containing the word "chicken", the search gives back a certain number of elements containing the word "chicken" and i want to take one of those elements with all the fields (calories, fat, protein, vit A, etc...) and store in another table so i can then tell it, "i want 200 grams of that element" and that that number "200" could multiply the content of each field. As you can see in the image, the output is a simple table, listing all the elements in the search, there is a checkbox, and i want it that when i check the checkbox, that this element with all the fields could be stored in another table. That's where the problem lies, I don't know what series of commands do i have to type in order to get that result, in other words how do i store that data into a variable or several variables in order to store it somehwere else.
result.JPG
result.JPG (110.35 KiB) Viewed 252 times