Announcement

Collapse
No announcement yet.

Insert whit foerach one row lookup

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Insert whit foerach one row lookup

    Code:
    $cont_por_cli_sql = "SELECT id_contactos
    	FROM cli_contactos
    	WHERE id_cliente = ".$CLIENTE."";
    
    sc_lookup(cpc,$cont_por_cli_sql);
    $CONT = count({cpc});
    $CONT2 = {cpc};
    $PERMISO = {permiso};
    $USUARIO = {id_usuario};
    echo "$CONT";
    echo "$CONT2";
    echo "{cpc}";
    
    foreach({cpc} as $contactos){
    	$insert_cli_sql = "INSERT INTO cli_permisos (id_usuario, id_contacto, permiso) 
    	VALUES (".$USUARIO.", ".$contactos.", ".$PERMISO." )
    	ON DUPLICATE KEY UPDATE permiso = ".$PERMISO."";
    	sc_exec_sql($insert_cli_sql);
    	}
    Array to string conversion

    ADOConnection.Execute(INSERT INTO cli_permisos (id_usuario, id_contacto, permiso)
    VALUES (9, Array, N )

    I'm try whit while and for, but only insert the first row in the insert an the second $contactos it's empty


    Code:
    $CONT = cont({cpc});
    
    $i = 1; 
    while ($i <= $CONT){ 
    
    $contactos = {cpc[0][$i]};
    
    	$insert_cli_sql = "INSERT INTO cli_permisos (id_usuario, id_contacto, permiso) 
    	VALUES (".$USUARIO.", ".$contactos.", ".$PERMISO." )
    	ON DUPLICATE KEY UPDATE permiso = ".$PERMISO."";
    	sc_exec_sql($insert_cli_sql);
            $i++;
    }

  • #2
    Because first is row, and then column

    Use {cpc[$i][0]}
    /Giuseppe

    Professional Scriptcase Services
    Some Customers opinions

    Comment


    • #3
      Gracias por tu pronta respuesta amigo Giu.
      Tanks for that quick response friend Giu

      Comment

      Working...
      X