There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
acer black screen blue screen boot bsod computer connection crash css dell display driver drivers email error excel explorer firefox firefox 3 game hard drive internet internet explorer itunes laptop lcd linux malware network networking nvidia outlook outlook 2003 outlook express partition printer problem ram router slow sound sprtcmd.exe trojan usb video virus vista windows windows xp wireless
Web Design & Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Internet & Networking > Web Design & Development >
Solved: php and mysql. complex copy table data to another table


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
firestormer's Avatar
Computer Specs
Senior Member with 1,353 posts.
 
Join Date: Sep 2005
Location: UK
Experience: Skilled: Know all i know and little else
30-Jun-2008, 09:00 AM #1
Solved: php and mysql. complex copy table data to another table
i need to create some php code that when called updates another table with different field names in the following way. Some are staight forward copies but others involve if statements.

old->new

user_id -> user_id
group_id -> group_id but if = 11 then set as 1 and if = 15 set as 2
username -> username
username -> display_name
user_password ->password
user_email -> email

also in the new

active needs to be set to 0 for all new records unless there is already a record with it set as 1

not that simple is it?

Thanks
__________________
You say deviant like its a bad thing...

TSG has made me snow blind.
Mudley's Avatar
Computer Specs
Senior Member with 100 posts.
 
Join Date: Apr 2008
Experience: Advanced
30-Jun-2008, 04:35 PM #2
pretty simple.

how many records are in the old table?
firestormer's Avatar
Computer Specs
Senior Member with 1,353 posts.
 
Join Date: Sep 2005
Location: UK
Experience: Skilled: Know all i know and little else
30-Jun-2008, 05:12 PM #3
Unknown as it's going to be run to syncronise two systems on a regular basis
Mudley's Avatar
Computer Specs
Senior Member with 100 posts.
 
Join Date: Apr 2008
Experience: Advanced
30-Jun-2008, 08:03 PM #4
your going to maintain two seperate databases with the same data? *veggie face*

ok. still simple, but you have to explain the active column.

all new records have active = 0
unless there is already a record with it set at 1 <-- what does this mean?
firestormer's Avatar
Computer Specs
Senior Member with 1,353 posts.
 
Join Date: Sep 2005
Location: UK
Experience: Skilled: Know all i know and little else
01-Jul-2008, 06:20 AM #5
It's ok. Basicly i've been trying to set up a cms and a board to share the same user data, names pw ect. originaly i tried to modify one table with extra fields to accomadate the cms and atempt to change the table name, but that failed.

What i was planning to do was every time a user tried loging in to the cms was to copy all the data from the board user table into the cms user table.

Instead i've now managed to set it so that when a user trys logging into the cms it runs a select query on the board user table searching for the username and copies that record into an array which is then proccessed into the right field names then the cms user table is checked for that user if the num of rows found is 1 then it runs and update query if 0 it inserts the data.

You might be worried about data concurency and stuff but i've disabled the cms's user preferences and stuff so that the user can't change their password/details in the cms.

SOLVED!
__________________
You say deviant like its a bad thing...

TSG has made me snow blind.
firestormer's Avatar
Computer Specs
Senior Member with 1,353 posts.
 
Join Date: Sep 2005
Location: UK
Experience: Skilled: Know all i know and little else
01-Jul-2008, 06:20 AM #6
Thanks for your time
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who help people like you solve computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 07:47 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.