Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function conectaDB ()
- {
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname="alumno";
- //crear conexion
- $conn = new mysqli($servername,$username,$password, $dbname);
- //Comprueba la conexion
- if ($conn->connect_error){
- return FALSE;
- }else{
- $conn->set_charset('utf8');
- return $conn;
- }
- }
- function leetabla($conn, $latabla='')
- {
- $consulta = "SELECT * FROM $latabla";
- $resultado = $conn->query($consulta);
- if($resultado->num_rows>0)
- {
- $arraydatos = array();
- while($file = $resultado->fetch_assoc()){
- $datos = array($file['dni'], $file['nombre'], $file['apellido']
- , $file['telefono']);
- $arraydatos[] = $datos;
- }
- return $arraydatos;
- }
- else return FALSE;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement