Ver Mensaje Individual
  #2 (permalink)  
Antiguo 08/04/2015, 04:51
superweb360
(Desactivado)
 
Fecha de Ingreso: abril-2015
Ubicación: España
Mensajes: 616
Antigüedad: 9 años, 1 mes
Puntos: 74
Respuesta: Usar un SELECT segun valor de variable

Código PHP:
Ver original
  1. <?php
  2. $con=mysqli_connect("localhost","my_user","my_password","my_db");
  3. // Check connection
  4.   {
  5.   echo "Failed to connect to MySQL: " . mysqli_connect_error();
  6.   }
  7.  
  8. $sql="SELECT Lastname,Age FROM Persons ORDER BY Lastname";
  9. $result=mysqli_query($con,$sql)
  10.  
  11. // Numeric array
  12. $row=mysqli_fetch_array($result,MYSQLI_NUM);
  13. printf ("%s (%s)\n",$row[0],$row[1]);
  14.  
  15. // Associative array
  16. $row=mysqli_fetch_array($result,MYSQLI_ASSOC);
  17. printf ("%s (%s)\n",$row["Lastname"],$row["Age"]);
  18.  
  19. // Free result set
  20.  
  21. ?>