<?php
       $con = new mysqli('localhost', 'piavant', 'p314-', 'fideliza');
       if ($con->connect_errno) {
             echo 'Error al conectar base de datos: ', $con->connect_error;
             exit();
       }
		if (isset($_GET['cod']) & $_GET['cod'] == "pi") {
				   $sql = 'SELECT textmsg FROM mensajes ORDER BY fechmsg DESC';
			 
				   $cursor = $con->stmt_init();
				   if ($cursor->prepare($sql)) {
						 $cursor->execute();
						 $cursor->bind_result($textmsg);
						 while($cursor->fetch()) {
								echo $textmsg."\n";
						 }
						 echo "\n";
						 $cursor->close();
				   }
	   }
       $con->close();
?>

