Jump to content

Problem copying a table, plz help


ukscotth

Recommended Posts

Hi,

 

Im trying to copy all data from one table into another while changing a few things on the fly. 

 

Basically I have a social networking site and i have a table which stores whos friends with who but I need to store the information in a different way, hence the new table.  The problem is with the code im using below it only copies one record for each member e.g if fred has 50 friends its only copying the data for 1 of them.

 

Hope that makes sens and hope someone can help, heres the code :

 

 




<?php 
include("include/config.inc.php");

$users = mysql_query("SELECT * FROM joovili_buddies");
						  

			while ($got_users = mysql_fetch_array($users)){


		 		$fid = mysql_query("SELECT * FROM joovili_users 
					WHERE username = '".$got_users['buddy_username']."' ");

  					if (mysql_num_rows($fid) == 0) {} else {

					$fid1 = mysql_fetch_array($fid); }


  			$fid2 = mysql_query("SELECT * FROM joovili_users 
			WHERE username = '".$got_users['buddy_buddy']."' ");

  			if (mysql_num_rows($fid2) == 0) {} else {

		$fid3 = mysql_fetch_array($fid2); }




mysql_query("INSERT INTO userlist (`userid`, `relationid`, `friend`) 

VALUES 

('".$fid1['id']."', '".$fid3['id']."', 'yes')");

}







?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.