<?php
       $con = new mysqli('localhost', 'piavant', 'p314-', 'fideliza');
       if ($con->connect_errno) {
             echo 'Error al conectar base de datos: ', $con->connect_error;
             exit();
       }
 
       $sql = "SELECT numelic FROM licencias WHERE codilic = '1'";
 
       if (isset($_GET['cod']) & $_GET['cod'] == "pi") {
			 
		   $cursor = $con->stmt_init();
		   if ($cursor->prepare($sql)) {
				 $cursor->execute();
				 $cursor->bind_result($numelic);
				 while($cursor->fetch()) {
						echo $numelic++."\n";
				 }
				 echo "\n";
				 $cursor->close();
		   }
		   //$sql = 'INSERT INTO licencias VALUES ( '1', '.$numelic.')';
		   $sql = "UPDATE licencias SET numelic = $numelic WHERE codilic = '1'";
		   $con->query ($sql);
	   }
       $con->close();
?>
