Ver Mensaje Individual
  #6 (permalink)  
Antiguo 12/09/2012, 15:00
jrsantos
 
Fecha de Ingreso: julio-2012
Mensajes: 25
Antigüedad: 11 años, 9 meses
Puntos: 3
Respuesta: Pasar Valor de Columna MySQL a Variable

Código PHP:
Ver original
  1. mysql_connect("localhost", "root", "root*") or die(mysql_error());
  2. mysql_select_db(contencion) or die(mysql_error());
  3.  
  4. $variable = "x";
  5. $datos = mysql_query("SELECT campo1, campo2 FROM tabla WHERE campo1='$variable'  ");
  6.  
  7. if (!mysql_num_rows($datos)) {
  8. echo "No existe datos para esta variable ";
  9. die();
  10. }
  11. while($row = mysql_fetch_array($datos)){
  12. $variable2 = $row ['campo2'];
  13. }
  14. echo $variable2;
  15. ?>

Saludos!