473,780 Members | 2,229 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

maintaining relation while POSTing and while fetching.

rpnew
188 New Member
Hello friends....
I'm developing one project in PHP-MySql on FC4.....
I'm facing a problem here at one place. Let me describe it....

I've one page in php on which i'm generating a table containing checkboxes for option. These options have suboptions. User need to chose these options and suboptions. with suboption they are getting textboxes in which they can enter values for suboptons. When they submit the form i need to get all these data and accordingly store them into the database.
Now problem comes because all these checkboxes and textboxes are generated dynamically meaning through values in database. So i've made an arrays for all these so that i can get the values of selected checkboxes and textboxes. So the problem is on the second page i cant determine which suboption and textbox value goes to which option means relation is broken i need to maintain this relation so that i can store these values in database maintaining foreign key..

Now let me describe my database a bit so that if you have any other option then this you can suggest me.

In database i've four tables say table1,table2,t able3 and table4.

Table1 contains name of OPTION and NUMBER of SUBOPTION it has.
Table2 contains name of SUBOPTIONS and OPTIONS they belongs(foreign key)

Table3 is similar to Table1 and Table4 is similar to Table2(with one field added which will store the value of SUBOPTION coming through TEXTBOXES which user is providing at runtime.)

So what i'm doing is getting the OPTIONS and SUBOPTIONS values from Table1 and 2 respectively and generating form. So when user submits the form i want to store these values into Table3 and 4 respectively.

I told you what i'm doing. so if you can help with that its good and if you have any other idea with GUI as well let me know.
Sep 3 '07 #1
16 1865
code green
1,726 Recognized Expert Top Contributor
This is a plan, not a problem.
I have to guess your problem is you don't know how to read form values.
Well you use the $_POST array to extract data from a form
Sep 3 '07 #2
rpnew
188 New Member
This is a plan, not a problem.
I have to guess your problem is you don't know how to read form values.
Well you use the $_POST array to extract data from a form

Yes you are right that its a plan and
you are wrong a bit that i dont know how to read form values...
well nope..
i know how to use $_POST or $_GET i'm doing that also but my problem is on the second page i'm getting all the values through three different arrays.. and i cant determine relationship between them so that while inserting into the table i can maintain foreign key relation...
And i'm sending and receiving this values as Arrays because all these CHECKBOXES and TEXTBOXES are generated through code according to database values so they'll have same name so to receive all the checked values i've to use Arrays.......

Well if you have any other way to do this let me know.. that will be very helpful

Regards,
RP
Sep 3 '07 #3
rpnew
188 New Member
hello friends please help.. im stuck here at this place very badly...


RP
Sep 4 '07 #4
pbmods
5,821 Recognized Expert Expert
Heya, RP.

What do you want your code to do? Give an example.
What is your code doing that you don't want it to do? Give an example.
What is your code *not* doing that it is supposed to? Give an example.
Sep 4 '07 #5
Atli
5,058 Recognized Expert Expert
Hi.

It would also help if you posted the code that generates the form on the first page.
Sep 4 '07 #6
rpnew
188 New Member
Heya, RP.

What do you want your code to do? Give an example.
What is your code doing that you don't want it to do? Give an example.
What is your code *not* doing that it is supposed to? Give an example.

What do i've in database?

As i told you earlier i've total of 4 tables......... ......
say in table1 two columns are there name and noofvariable
table two has name(foreign key to table1), variablename

table3 is same as table1
table4 is same as table2 with one column added that is variablevalue.. ....


now what i'm doing?


from table1 and table2 i'm generating one form which contains checkboxes and textboxes......
like checkboxes for "name" its respective "variablename"( variables) and textboxes for these "variablena me" so that user can put values in that.....

what i want.... when user submits i want... whatever the name and variable checked store them to table3 and table4 accordingly.... . also if user have provided values in textbox store them into table4......... ..

problem i'm facing...

As all these fields are generated dynamically means through code.... so i cant provide different names to checkboxes....s o they are an array.... like one array for 'name' checkbox one for 'variablename' checkbox and one for 'textfield'....

well through this i can receive all the checked variables and textvalues entered on second page but on second page i cant determine which 'variablename' goes to which 'name'.....

Regarding code
well on first page i'm simply using while loop to generate the form according to database and on second to get the values i'm using foreach loop to access arrays.... so even i want to know that if there is another way to access the array...
i've tried many things so i dont have a exact code now......and frankly i dont have any idea if at all this can be done as on second page you dont which variables are coming and how many(if using different names for all) as there can be as many as 100.... depending upon users selection......
Sep 4 '07 #7
code green
1,726 Recognized Expert Top Contributor
As all these fields are generated dynamically means through code.... so i cant provide different names to checkboxes
If the checkboxes are generated within a loop [PHP]for($c=0; etc...)[/PHP]Then you can create a name for the checbox dynamically
[PHP]echo '<input type="checkbox" name="mybox'.$c .'"id="'.$c.'"> Choice '.$c;[/PHP] If this idea does not suit then it is possible to send an array as a url variable.
It needs to be declared as such in HTML.
Can't remember how but it is simple
Sep 5 '07 #8
rpnew
188 New Member
If the checkboxes are generated within a loop [PHP]for($c=0; etc...)[/PHP]Then you can create a name for the checbox dynamically
[PHP]echo '<input type="checkbox" name="mybox'.$c .'"id="'.$c.'"> Choice '.$c;[/PHP] If this idea does not suit then it is possible to send an array as a url variable.
It needs to be declared as such in HTML.
Can't remember how but it is simple
well yes i'm doing that... but my problem is to maintain relation between two arrays to store it into the tables..

however.. dont worry.. i've solved my problem at last.....

thanks for the reply.....

RP
Sep 5 '07 #9
code green
1,726 Recognized Expert Top Contributor
Glad you solved your problem.
but my problem is to maintain relation between two arrays to store it into the tables..
What about a 2d array?
Sep 5 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

2
1717
by: auke | last post by:
Hi, I've got two tables (both with a primary key) which are related through a one-to-one relation (for security reasons). Both tables store information about people. The information in the first table should be accessible for everyone, while the information in the second table should only be accessible to a select group of users. So the setup is something like this: Table 1 Table 2
2
2038
by: deko | last post by:
ALTER TABLE DROP CONSTRAINT ; Is this syntax correct? The error I'm getting is: Error Number 3199: Could not find reference. I tried it without the curly braces, but no luck.
7
3854
by: Wayne Brantley | last post by:
I have found what appears to be an error in streaming with Datasets. It causes an error of 'Cannot find relation 0' when recreating the dataset from a stream. Here is how you reproduce it. Lets assume you have tables like this: Customers CustomerName: Varchar(50) CustomerNumber: Int (Primary Key)
1
971
by: gaffar | last post by:
Hello Sir, I have created database(ms access) and tables at runtime how to maintain relation ships between the tables. by using vb.net. Thanking u sir.
7
2740
by: Juris Krumins | last post by:
I have a problem with postgresql tables. periodicaly, I would say frequently about 5-10 time per hour i have such errors in my server log file: 2004-04-14 12:23:32 ERROR: cache lookup of relation 149064743 failed 2004-04-14 12:23:32 ERROR: Relation "tmp_table1" does not exist 2004-04-14 12:23:32 ERROR: Relation "tmp_table1" does not exist So turn on debugging options and have that's what i got:
0
2913
by: Ambica Jain | last post by:
I have a data grid called Files, which has some columns like FileName, Col1, Col2, ... , Col8. Then i have a combobox which allows user to select from Col1 to Col8 and based on this selection, i generate a report from data in grid Files. It displays like (e.g. is Col1 is selected): Col1 Count ---------------------- Val1 x Val2 y .....
4
4342
by: Sam | last post by:
I have an asp.net 2.0 app that uses a sitemap, Master Page, and has several content pages. While this feature has simplified the process of creating a data-driven site menu, it does seem to have some big restrictions. Namely, maintaining state on the Master Page across all content pages. I simply want to keep track of a key value across all content pages. The only solution I can come up with is using a session variable, which I hate.
1
1826
by: Bhavesh | last post by:
Hi Bruce, Thanks For Reply. U were right, Needed to pass string , but also need to pass size of Data( instead of 16, passed actual length of data). So that worked for me & didn't get any error. But now problem in fetching, not able to fetch data from table correctly. Here is my code. I hav following problems with this coding
3
1658
by: eschneider | last post by:
Just some common issues with WS: Using custom objects: When objects change, seems you are always fixing some issue. Update references, which sometimes does not work. Deployment: Weird errors which take a while to fix because the error stink: Forget to set ASP.NET 2.0="Parser Error Message: Could not load type" '*.Global' is ambiguous: it could come from assembly=I deleted the
0
9474
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10139
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9931
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8961
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7485
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6727
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5373
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3632
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2869
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.