Foro de elhacker.net

Programación => PHP => Mensaje iniciado por: DiTeN en 7 Diciembre 2009, 03:02 am



Título: cargar select desde mysql
Publicado por: DiTeN en 7 Diciembre 2009, 03:02 am
tengo este codigo, algo me anda mal...
me podrian ayudar con que es___

Código
  1. <select name="element">
  2. <?php
  3.  
  4.    try
  5.    {
  6.        /*** query the database ***/
  7.        $result = obligatoriodbDB::getInstance()->query("SELECT * from categorias");
  8.  
  9.        /*** loop over the results ***/
  10.        foreach($result as $row)
  11.        {
  12.            /*** create the options ***/
  13.            echo '<option value="'.$row['atomicnumber'].'"';
  14.            if($row['atomicnumber']==42)
  15.            {
  16.                echo ' selected';
  17.            }
  18.            echo '>'. $row['english'] . '</option>'."\n";
  19.        }
  20.    }
  21.    catch(PDOException $e)
  22.    {
  23.        echo 'No Results';
  24.    }
  25. ?>
  26. </select>

gracias Saludos


Título: Re: cargar select desde mysql
Publicado por: Toxico en 8 Diciembre 2009, 15:25 pm
Q error te muestra?


Título: Re: cargar select desde mysql
Publicado por: дٳŦ٭ en 8 Diciembre 2009, 20:41 pm
Se llaman excepciones:

http://php.net/manual/en/language.exceptions.php

Dinos que error te sale?