title: Cron php update/insert one sql table from another
body: <p>I am not that good in php so I would appreciate your help.</p>
  
  <p>I need to update or insert certain data from one mysql table to another mysql table same server!</p>
  
  <p>Bought tables have same column and what I want is to update certain rows with prechosen mid!
  Table:</p>
  
  <pre><code>|ID| |mid| |value1| |value2|
  </code></pre>
  
  <p>I did the part where php for update or insert to check if it exists but what I need it to do is to repeat the step pos each given</p>
  
  <p>So what I need it to repeat this script for each mid I list to be done </p>
  
  <pre><code>mid1 = 66
  mid2 = 78
  mid3 = 24
  
  
  $con = mysql_connect("localhost","User","Pass");
  if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
  
  mysql_select_db(baza, $con);
  
  $result = mysql_query("SELECT * FROM table WHERE mid='???' ");
  
  while($row = mysql_fetch_array($result))
  {
  $mid=$row['mid'];
  $name=$row['value1'];
  $alias=$row['value2'];
  }
  
  mysql_close($con);
  ?&gt; 
  &lt;?php
  $con2 = mysql_connect("localhost","user2","pass2");
  if (!$con2)
  {
  die('Could not connect: ' . mysql_error());
  }
  
  mysql_select_db(baza2, $con2);
  
  
  $query = "SELECT * FROM table WHERE mid='$mid' ";
  $resulta = mysql_query($query) or die(mysql_error());
  
  if (mysql_num_rows($resulta) )
  {
  
  mysql_query("UPDATE table SET mid='$mid', name='$name', alias='$alias'");
  mysql_close($con2);
  echo "1 record added1";
  }
  else
  {
  $sql="INSERT INTO table (mid, name, alias)
  VALUES
  ('$mid','$name','$alias')";
  
  if (!mysql_query($sql,$con2))
  {
  die('Error: ' . mysql_error());
  }
  echo "1 record added";
  mysql_close($con2);
  }
  </code></pre>
  
  <p>Thank you in advance!</p>