• Welcome to NamesLot.com Domain Name Forum

    NamesLot.com Domain Name Forum offers a fully open forum to discuss domain industry news and a 0% commission marketplace for you to buy and sell domain names.

    We have reorganized our Marketplace so now it is easier to get attention to your domain while it is also easier for buyers to find the right domain name.

    If you want us to add more threads to our marketplace, please contact us! Listing on our marketplace as always, 100% free! Register NOW or Login HERE!

How to code dynamic database update.

Status
Not open for further replies.

jignesh

New Member
Hello,
i want to know how to update or add any field in database dynamically.
eg.
there is one user interface form in which 10 fields. now if we want to add one more field in that form than we need to add that in DB also.so what i want to know is.if i add that field in form it must add in to DB also.

i hope u understand my query, if u have any resources than plz post here.

thanks
 
I did thought like you in the beginning. One friend of mine also thought like you. But I can tell you that it can be achieved with Alter table query.

Which I wouldn't recommend.

If you can specify some more details then I can achieve the same thing without adding a new field in the table.

Thanks.
 
I know about alter table but i have one study project where i need implement that script.i will explain whole situation in details here a'ter requirement gathering of the dynamic database.
 
I have one basic idea right now which can be a base for the further developments. Do one thing make another table called dyn_table or something like that. Now you can create some columns like:
ID - Auto increment, primary key
Field - Varchar
Data - Varchar or text as per need
Mapping - Varchar

Now whenever a new feild is inserted just insert that new field data into this table.
ID will be auto incremented.
Field will be the field name [Ex: Phone number]
Data will be the data which user inputs.
Mapping this will contain the ID of the entry of the original table. Which would also be a unique one.

When fetching the data for a person you can fetch it regularly from the original table and just run one more query on the dyn_table which will fetch all the extra fields inserted for that particular person's row.

This will give it extra flexibility giving you a free hand to generate dynamic fields maybe 2 sometimes and maybe 1 at other time.

Thanks. :grin: BTW the above things are creations of an idle mind :grin: Like mine. So if you think it is confusing one then please don't hesitate to ask your questions.
 
i go through the reply and i understand what u mean to say. i have implemented those things before,and really work correctly for me.thanks for the idea i will ask u if find any difficulties.
 
Now i m giving the exact requirement in that study project,
see there is one entity and it have around 10 attributes.now i want to add any more attrubute than in traditional fasion what we have to do is we need to update database manually.i want that when we add field in to that form it should automatically add that in DB also.
for exp.

one page is student.php

now in this page there is 10 attributes called name,age,student id etc...
so this form is to fill student information now if i want to add one more field called student class than i have to add <input type="" name="" value=""> for that field and i also add that field in DB.
so i want that when i add <input type="" name="" value=""> it should also added in to db. it should not like we need to add one new field by enter in localhostphpmyadmin and add one new field in to that table.

i think u can understand my doubt now.

thanks
 
Got it. As stated above the previous solution would solve the problems out.

If you have any doubts then please don't hesitate to ask. Thanks.
 
Status
Not open for further replies.

Members online

No members online now.

Forum statistics

Threads
19,801
Messages
69,798
Members
44,585
Latest member
tsscgroup
Active members today
0
New members today
0
New threads today
2
New posts today
2

Follow NamesLot on Twitter!

NamesLot proudly supported by

NamesLot proudly supported by

Top