Solved

Is there a way to automatically copy table data into a different table when it is submitted?

Posted on 2010-09-03
7
379 Views
Last Modified: 2012-05-10
I'd like to have a table automatically update another table when new data is entered . The tables will have 2 different names but similar fields if not all the same.

Is this possible?
Is there a snippet of  code, module, or plugin that can do this?

Thanks in advance.
0
Comment
Question by:colonelblue
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 11

Accepted Solution

by:
lenordiste earned 125 total points
ID: 33601314
you could use a trigger to update the second table.

here is a starting point:
http://dev.mysql.com/doc/refman/5.0/en/triggers.html
0
 
LVL 12

Assisted Solution

by:Rok-Kralj
Rok-Kralj earned 125 total points
ID: 33602013
I would personally solve this problem on php's level. If you have mysql_query() wrapped any way, you could just search for "INTO yourtable" to detect insertion and then perform necessary actions.

Apart from that, I suspect there is something wrong with the database/table design.
0
 
LVL 25

Expert Comment

by:lenamtl
ID: 33602801
Could you explain a little bit more what you try to achieve, are you looking for a specific bridge?
In the past I used Fabrick component http://fabrikar.com to make some complexe things this can help you.
0
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 

Author Comment

by:colonelblue
ID: 33603982
Hello experts and thank you for your replies.


The very purpose of why I am trying to replicate data from one table to another is to take advantage of a plugin that uses a zipocde proximity finder.

So how did I get here?

I was required to have an events application working for a site. Everything the Eventlist module can do, including having a calendar module and front-end input/edit form and nice layout.
But what it lacked was a search function based on zip codes (postcodes) which is the top requirement. I found that Sobi2 has a search function based on zip codes AND an extra plugin for it to use as a proximity finder.

Having both installed, the problem now is that they write to two different tables.
I had found a "module" someone made last year apparently from here: http://www.sigsiu.net/forum/index.php/topic,17407.10.html and included the zip if anyone is interested. However it does not work. No events show up in the module and the tables do not seem to see each other.

Now I thought I should just keep Sobi2 and it's handy zip code functions and not use Eventlist but Eventlist has that nifty little calendar and modules that make it so easy for the user.
SO I thought what if a user entered their data into EventList and then have that data replicated into the Sobi2 table? Then I can use both functions.


Again thank you for your expert advice.

mod-sobi2-eventlist.zip
0
 
LVL 1

Assisted Solution

by:dhaval_neesa
dhaval_neesa earned 125 total points
ID: 33605567
you can use the trigger for your problem
mysql> use shamun
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;

+------------------+
| Tables_in_shamun |
+------------------+
| contacts         |
| forum            |
+------------------+

2 rows in set (0.00 sec)

mysql> delimiter ;;
mysql> create trigger foo
-> after insert on forum
-> for each row
-> begin
-> insert into contacts (email) values ('example@abc.com');
-> end
-> ;;
Query OK, 0 rows affected (0.31 sec)

mysql> delimiter ;


// daily query
mysql> insert into forum (status) values ('open');
Query OK, 1 row affected, 13 warnings (0.00 sec)

mysql> select *from forum;

+----+--------+---------+------+------+------+
| id | status | subject | date | time | user |
+----+--------+---------+------+------+------+
|  2 | open   | NULL    | NULL | NULL | NULL |
+----+--------+---------+------+------+------+

1 row in set (0.00 sec)

mysql> select email from contacts;

+-----------------+
| email           |
+-----------------+
| example@abc.com |
+-----------------+

1 row in set (0.00 sec)

mysql>

http://dev.mysql.com/doc/refman/5.0/en/triggers.html
0
 
LVL 7

Assisted Solution

by:Vimal DM
Vimal DM earned 125 total points
ID: 33674587
hai,

I suggest you to study about the 'Cursors -' and DB that you want.

Where we can easily make the automatic update and what ever the functionality that you need.


Thanks.
0
 

Author Closing Comment

by:colonelblue
ID: 33873019
I could not figure this out.
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question