Ver Mensaje Individual
  #3 (permalink)  
Antiguo 20/05/2015, 03:03
chigorin4
 
Fecha de Ingreso: mayo-2015
Mensajes: 11
Antigüedad: 9 años
Puntos: 0
Respuesta: Problemas al hacer un select con mysql

Código PHP:
Ver original
  1. <?php
  2.     $user = 'root';
  3.         $password = 'root';
  4.         $db = 'contecxtualc';
  5.         $host = 'localhost';
  6.         $port = 8889;
  7.         $link = mysql_connect(
  8.        "$host:$port",
  9.        $user,
  10.        $password
  11.     );
  12.     $db_selected = mysql_select_db(
  13.        $db,
  14.        $link
  15.     );
  16.     mysql_set_charset('utf8');
  17.  
  18.     $tema = $_POST['TEMA'];
  19.  
  20.     $q = "SELECT * from archivos WHERE tema = '" . $tema . "' ORDER BY id DESC;";
  21.     $rq = mysql_query($q);
  22.     $arreglo = array();
  23.     $i = 0;
  24.     while($fa = mysql_fetch_array($rq))
  25.     {
  26.         $arreglo[$i] = array($fa[autor],$fa[tema],$fa[link]);
  27.         $i++;
  28.     }
  29.     echo json_encode($arreglo);
  30.    
  31.    
  32. ?>