473,791 Members | 3,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
16 1866
rpnew
188 New Member
Glad you solved your problem.
What about a 2d array?
Well i've three arrays actually to manage.. to maintain their relation what i've done is....
The first one is aa array which contains values of CHECKBOXES..
The second one is also an array of CHECKBOXES(valu es of checkboxes)
The third is an array of TEXTBOXES..

Now i've given the name of the TEXTBOXES as content(value) of the second array(CHECKBOXE ) and For name of the Second array i've taken content(value) of the first array(CHECKBOX) ... and passed the first array across the pages....

So on the second page i'm already getting first array.. to get value of second array i'm using first array value and to get the third one i'm using value of the second array.. in that way by passing only one array i can access all three arrays... and relation is also maintained..

RP
Sep 6 '07 #11
code green
1,726 Recognized Expert Top Contributor
You could possibly improve this by using an associative aray and naming the keys the same as checkbox/textbox name
Sep 6 '07 #12
pbmods
5,821 Recognized Expert Expert
Heya, RP.

You may find this document of some interest.
Sep 6 '07 #13
rpnew
188 New Member
You could possibly improve this by using an associative aray and naming the keys the same as checkbox/textbox name

hi......
well thanks for your suggestion..... but i dont know how to use associative array so if you can give me some information it will be useful....howev er i'll also try to search it on net..

Thanks,
RP
Sep 6 '07 #14
rpnew
188 New Member
Heya, RP.

You may find this document of some interest.

Thanks to you as well..

RP
Sep 6 '07 #15
code green
1,726 Recognized Expert Top Contributor
A little example using associtive arrays
[PHP]$assocArray = array();
$nBoxes = 3;
for($c=0;$c<$nB oxes;$c++)
{
$name = 'box'.$c; creates a string called 'box' with a numeric suffix
$value = 'Any string '.1;

$assocArray[$name] = $value;
echo '<input type="textbox" name="'.$name.' id="'.$c.'value ="'.$value.' >';
}
//Creates an array such
assocArray ('box0'=> 'Anystring 0','box1'=> 'Anystring 1','box2'=> 'Anystring 2')
//

//Read array
foreach($assocA rray as $key=>$value)
{
echo 'Name = '.$key;
echo ' Value = '.$value.'<br>' ;
}
//Will output
Name = box0 value = Anystring 0
Name = box1 value = Anystring 1
Name = box2 value = Anystring 2
//Or at least it should do [/PHP]
Sep 6 '07 #16
rpnew
188 New Member
A little example using associtive arrays
[PHP]$assocArray = array();
$nBoxes = 3;
for($c=0;$c<$nB oxes;$c++)
{
$name = 'box'.$c; creates a string called 'box' with a numeric suffix
$value = 'Any string '.1;

$assocArray[$name] = $value;
echo '<input type="textbox" name="'.$name.' id="'.$c.'value ="'.$value.' >';
}
//Creates an array such
assocArray ('box0'=> 'Anystring 0','box1'=> 'Anystring 1','box2'=> 'Anystring 2')
//

//Read array
foreach($assocA rray as $key=>$value)
{
echo 'Name = '.$key;
echo ' Value = '.$value.'<br>' ;
}
//Will output
Name = box0 value = Anystring 0
Name = box1 value = Anystring 1
Name = box2 value = Anystring 2
//Or at least it should do [/PHP]

hmm well thats an useful example..

Thanks,
RP
Sep 7 '07 #17

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
3856
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
2743
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
4344
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
1661
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
9666
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9512
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
9987
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...
1
7531
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
6770
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
5424
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...
0
5552
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3709
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2910
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.