473,804 Members | 2,126 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

insert for cross compatibility

14 New Member
sorry all i ever seam to do here is ask questions:(

but im really stuck on the best way to do this

what i have is 2 tables and im trying to make a 3rd table for compatibility

example
table 1
id
data
name
data1

table2
id
data
supplier
data2

what i want is a 3rd table

table3
id
table1 id
table2 id

thats easy but i want a php way of easy editing ti

main page
list all opetions in table 1 as links
[php]<?php
//connect to mysql
//change user and password to your mySQL name and password
mysql_connect(" localhost","use rname","passwor d");
//select which database you want to edit
mysql_select_db ("database") ;
//select the table
$result = mysql_query("se lect * from table1");
//grab all the content
while($r=mysql_ fetch_array($re sult))
{
//the format is $variable = $r["nameofmysqlcol umn"];
//modify these to match your mysql table columns
$id=$r["id"];
$data=$r["data"];
$name=$r["name"];
$data1=$r["data1"];
//display the row
echo "<a href='main1.php ?id=$id'>add compatibility for $name </a><br>";
}
?>[/php]the main1.php

on this one i want to show all the items in table 2 with check boxes
you can check the boxes and then when submit it adds an entry into table 3 for each cecked option

example

id table1_id table2_id
1,1,1
2,1,2
3,1,3
ect

where id is the table 3 id
table1_id is the id from table 1 ( passed through the link)
table2_id is the id from table 2 ( pulled down in this page)

its this page i am not sure how to do . i can do the pull down fine but doing the check boxes and the table insert i am unsure of

andy help will be greatly recived

2nd remark: Please enclose your posted code in [code] tags (See How to Ask a Question).

This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

Please use [code] tags in future.

MODERATOR
Mar 23 '08 #1
2 1425
dlite922
1,584 Recognized Expert Top Contributor
sorry all i ever seam to do here is ask questions:(

but im really stuck on the best way to do this

what i have is 2 tables and im trying to make a 3rd table for compatibility

example
table 1
id
data
name
data1

table2
id
data
supplier
data2

what i want is a 3rd table

table3
id
table1 id
table2 id

thats easy but i want a php way of easy editing ti

main page
list all opetions in table 1 as links
[php]<?php
//connect to mysql
//change user and password to your mySQL name and password
mysql_connect(" localhost","use rname","passwor d");
//select which database you want to edit
mysql_select_db ("database") ;
//select the table
$result = mysql_query("se lect * from table1");
//grab all the content
while($r=mysql_ fetch_array($re sult))
{
//the format is $variable = $r["nameofmysqlcol umn"];
//modify these to match your mysql table columns
$id=$r["id"];
$data=$r["data"];
$name=$r["name"];
$data1=$r["data1"];
//display the row
echo "<a href='main1.php ?id=$id'>add compatibility for $name </a><br>";
}
?>[/php]the main1.php

on this one i want to show all the items in table 2 with check boxes
you can check the boxes and then when submit it adds an entry into table 3 for each cecked option

example

id table1_id table2_id
1,1,1
2,1,2
3,1,3
ect

where id is the table 3 id
table1_id is the id from table 1 ( passed through the link)
table2_id is the id from table 2 ( pulled down in this page)

its this page i am not sure how to do . i can do the pull down fine but doing the check boxes and the table insert i am unsure of

andy help will be greatly recived

2nd remark: Please enclose your posted code in [code] tags (See How to Ask a Question).

This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

Please use [code] tags in future.

MODERATOR
Sorry for the late response, some of use don't go digging in old posts. (old = past several days)

Perhaps we can help if we knew what those were and what you're trying to attempt instead of explaining at the programming level.

What does this system do? What are the names (or who) and what's the suppliers role (besides obviously supply), if any.

We might help you build a better way of doing things or help you finish.
May 13 '08 #2
dlite922
1,584 Recognized Expert Top Contributor
Also, I think what you're trying to do is build a many-to-many relationship, commonly solved by having a "link" table.

Example of a many to many relationship is for example

Table Actors
id
name
age

Table Movies
id
title
year


Movies can have *many* actors, and actors can have *many* movies. How you solve this is with a link table.

Table Starring
id
movie_id
actor_id

Example Data in Table this link table would look like this

1, 456, 234
2, 239, 290
3, 456, 120
4, 456, 290

The second pair of numbers in each row are foregin keys to the the first two tables of course.

Actor with id 290 has two movies, movie number 239 and 456. And Movie 456 also has actor 120 as another starring actor.

Hope that makes sense to you, and is related to your problem.
May 13 '08 #3

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

Similar topics

4
5481
by: Simba | last post by:
In some pages of my website I use a code like the following: for (var n = 0; n < getTagsArray("SPAN").length; n++){ //SPAN is just an example. I also use other tags tag = getTagsArray("SPAN"); //make something with tag... }
0
1063
by: Another DB2 UDB DBA | last post by:
The documentation describes cross-platform backup compatibility between Solaris, AIX, and HP-UX, presumably because UltraSPARC, PA-RISC, and POWER processors are all big-endian. Does the recent introduction of DB2 UDB V8.2 for Linux on POWER5 servers mean that it will be cross-platform compatible with Solaris, HP-UX and AIX? Fred
6
10639
by: Larry Johnson | last post by:
I have two similar SQL Server databases each with a table named Payments. PaymentID is an identity field and the primary, unique, key in both tables. There is one other key but it is not unique. The same INSERT command works for one table but not the other. The error is "...didn't add 1 record due to key violations". Since the tables apper to be identical as far as I can tell, I suspect the error message really means something else. ...
17
1798
by: Mark Rae | last post by:
Hi, I'm interested in your opinion concerning how far you would consider it necessary to code for cross-browser compatibility these days, especially for public-facing Internet sites... According to a recent survey (http://www.weboptimiser.com/search_engine_marketing_news/3061148.html), Internet Explorer has just under 95% of the browser marketplace. Do you think it's worth the additional aggravation of making things work in
2
1703
by: Lüpher Cypher | last post by:
Does anyone know of good links about cross-browser compatibility (html attributes/css2/javascript)? -- - lüpher --------------------------------------------- "Man sieht nur das, was man weiß" (Goethe)
15
2333
by: CMM | last post by:
So I'm half way through overseeing a large project in ASP.NET 2.0. My superiors have decided that it would be nice if we ensured the site worked on all the major platforms (as they see it: IE, FireFox, and Safari). We've made heavy usage of the new MENU control and other intrinsic 2.0 controls.... nothing fancy! just using ASP.NET's built-in controls and very nice, pervasive, and clean usage of CSS. Now I find after more testing that the...
1
3648
by: Iwan Petrow | last post by:
Hi, I do this - take some data with sqldataadaptor (at this moment 2000rows) in fill datatable. For each two rows do some calculations and save data to the database with insert command. (the data which I insert are 5 int values for each two rows - so 2000*1999 insert commands) In this way it is very slow. I think this is because of the invoking so
6
3722
by: lenygold via DBMonster.com | last post by:
Hi everybody: What is the best way to I have 10 tables with similar INSERT requiremnts. INSERT INTO ACSB.VAATAFAE WITH AA(AA_TIN, AA_FILE_SOURCE_CD, .AA_TIN_TYP) AS ( SELECT AA_TIN, AA_FILE_SOURCE_CD, .AA_TIN_TYP FROM VAATAFAA WHERE AB_TP_ACNT_STAT_CD <0),
2
3755
by: lenygold via DBMonster.com | last post by:
Hi Everebody: I have a table: CREATE TABLE CROSS_REFERENCE (ROW# INTEGER NOT NULL ,KEY_WORD CHAR(16) NOT NULL ,QUERY_DESCR VARCHAR(330) NOT NULL ,PRIMARY KEY (ROW#,KEY_WORD)); It is a cross reference table to my CATALOG Table based on key words.
0
9711
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
10595
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10335
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9169
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
7633
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
6862
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
5668
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4306
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.