Jump to content

loop on mysql INSERT ends up in uploading only 1 row


timmyd

Recommended Posts

loop on mysql INSERT ends up in uploading only 1 row

 

 

  function link_id() {
    return $this->Link_ID;
  }

  function query_id() {
    return $this->Query_ID;
  }
  function query($Query_String) {
    $this->Query_ID = @mysql_query($Query_String,$this->Link_ID);
  }
  

  function connect($Database,$Host,$User,$Password) {
    if ( 0 == $this->Link_ID ) {
      $this->Link_ID=mysql_connect($Host, $User, $Password);
      if (!$this->Link_ID) {
      }
      if (!@mysql_select_db($Database,$this->Link_ID)) {
        $this->halt("cannot use database ".$this->Database);
        return 0;
      }
    }
    return $this->Link_ID;
  }  
  
$db=new db_connect;

$x = "SELECT * FROM table1";
$db->query($x);
   while($db->next_record()){
             $id =$db->f("id");
             
	$y= "INSERT INTO table2 (id2) values('".$id."')";
	$db->query($y);	
	}

 

whats stopping the loop?

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.