Re: Re: insterting data into table.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Masud,

Many thanks for the coding suggestion. I will try to use this code today. 

I hope it works out. 

Thanks , 

WArm Regards,

Tarun.


  ----- Original Message ----- 
  From: iammasud 
  To: php-objects@xxxxxxxxxxxxxxx 
  Sent: Sunday, January 20, 2008 10:49 PM
  Subject:  Re: insterting data into table.


  Dear Tarun

  [I made a correction in my previous code.]

  The problem you stated here is related to merging two tables into 
  one. You want to do it with a php script page. But for this job, you 
  don't need page redirection. If you nedd page redirection for anoher 
  reason...pls describe your prob more detail. 

  For MySQL:

  If you have table1 defined with the columns or fields (product_code , 
  image_path , product_name) and table2 with the columns (product_code, 
  size, ...other details), just make required new columns in table2 
  with dummy values like "abc" or null; the columns should be same as 
  those in table1 (e.g. image_path, product_name). Now get all values 
  form table1 and then insert the values into table2 using UPDATE 
  command and matching the primary key. Example follows (without noting 
  connection):

  For PHP:

  $query1 = "SELECT * from table1;";
  $rows = mysql_query($query);
  //...you can add check for successful query (Optional)

  foreach($rows as $row)
  {
  $product_code_from_table1 = $row["product_code"];
  $query2 = "UPDATE table2 SET field_1=value_1,...,field_n = value_n 
  where product_code=$product_code_from_table1;"
  $result=mysql_query($query2);
  //...you can add check for successful query (Optional)
  }

  Hope it will work...(if any syntax error, i m sorry...in such a case 
  you should find out the errors in the code or can ask for further 
  help).

  N.B.: For more help, $query2 should be as follows:
  $query2 = "UPDATE table2 SET image_path=$row['image_path']...
  where product_code=$product_code_from_table1;"

  BR
  Masud

  --- In php-objects@xxxxxxxxxxxxxxx, "Tarun" <tarun.virgo@...> wrote:
  >
  > hello friends,
  > 
  > i have two diff tables. in mysql.
  > 
  > one table has ( product code , image path , product name)
  > 2nd table has ( product code, size, other details)
  > 
  > now i want to make them a single table.
  > 
  > 
  > i thought that....i make a php script, which calls product code 
  from one table, matches with other table, and then select the DETAILS 
  from one table and insert in 2nd table
  > 
  > so i want to make a URL redirect script.
  > 
  > can you help me out to write a redirect script. or suggest me what 
  is the automatic redirect code , which redirects to specified url in 
  2 seconds. So a automatic page reloading happens and data is 
  transferred to another table.
  > 
  > Warm Regards,
  > 
  > Tarun
  > 
  > 
  > 
  > [Non-text portions of this message have been removed]
  >



   

[Non-text portions of this message have been removed]


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux