06.09.2014 Views

Bases de datos: Software libre - Universitat Oberta de Catalunya

Bases de datos: Software libre - Universitat Oberta de Catalunya

Bases de datos: Software libre - Universitat Oberta de Catalunya

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

© FUOC • 71Z799014MO 11 Desarrollo <strong>de</strong> aplicaciones en conexión con bases <strong>de</strong> <strong>datos</strong><br />

Recuperando el ejemplo inicial, entre las líneas 7 y 21:<br />

7 // Realizando una consulta SQL<br />

8 $query = ‘SELECT * FROM mi_tabla’;<br />

9 $result = mysql_query($query,$link) or die(‘Consulta errónea: ‘ . mysql_error());<br />

10<br />

11 // Mostramos los resultados en HTML<br />

12 echo “\n”;<br />

13 while ($line = mysql_fetch_array($result, MYSQL_BOTH)) {<br />

14 echo “\t\n”;<br />

15 for($i=0;$inombre . ““;<br />

16 echo “Apellidos: “ . $object->apellidos . ““;<br />

17 echo “\t\n”;<br />

18 }<br />

19 echo “\n”;<br />

• $valor = mysql_result($recurso,$numero_<strong>de</strong>_fila,$numero_<strong>de</strong>_campo)<br />

Esta función consulta directamente un valor <strong>de</strong> un campo <strong>de</strong> una fila especificada.<br />

Pue<strong>de</strong> ser útil si queremos conocer un resultado sin necesidad <strong>de</strong><br />

realizar bucles innecesarios. Evi<strong>de</strong>ntemente, hemos <strong>de</strong> saber exactamente<br />

dón<strong>de</strong> se encuentra.<br />

• $exito = mysql_data_seek($recurso,$fila)<br />

Esta función permite mover el puntero <strong>de</strong>ntro <strong>de</strong> la hoja <strong>de</strong> resultados representada<br />

por $recurso, hasta la fila que <strong>de</strong>seemos. Pue<strong>de</strong> ser útil para

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!