Hi everyone,
I am translating what Marco says in his email:
=======================
Hola Marco,   Con tu permisi�n estoy traduciendo al ingles lo que dices en tu email.
Rizwan.
=======================
Good morning everyone:

I hope some of you speak Spanish and can help me to find out what is wrong with the 
following code:

The objective of the function is to access a database (MySQL) and display the records 
that meet a certain condition.
If there are no records matching the condition, the function should display a message 
to the user informing
of that situation, in an otherwise situation, display the matching records in a table 
together with options of
"Delete" or "Modify".
The function should do at least this.  The problem is that it does not display the 
first matching record but displays
all the rest of them. I have tried a thousand time reviewing the code but have not 
been able to find the error.

function display_articles_admin($boletin)
{
if (!$boletin == NULL)
       {
        $conn = db_connect();
        $query = "select id_articulo, titulo_articulo, autor_articulo from 
articulo_boletin where id_boletin=$boletin";
        $result = mysql_query($query, $conn);
        $row = 0;
        $hay_arts = mysql_fetch_row ($result);
        if ($hay_arts)
        {
                        echo "<h1>Articles belonging to Bulletin $boletin</h1>";
                echo "<p>\n
                <table width=\"70%\" align=\"center\" cellspacing=0>\n
                        <tr>\n
                                <td><b>Article Detail</b></td>\n
                                <td align=\"center\"><b>Eliminar</b></td>\n
                                <td align=\"center\"><b>Editar</b></td>\n
                        </tr>";
                        while ($fila = mysql_fetch_array($result,MYSQL_NUM))
                        {
                                $row++;
                                echo "<tr bgcolor=\"".color_fila($row)."\">\n";
                                
echo"<td><p><b>$fila[2]</b><br><i>$fila[3]</i></p></td>\n";
                                echo "<td align=\"center\"><a 
href=\"proces.php?action=delart&articulo=$fila[0]\">
                                        <img src=\"../boletines/ima/eliminar.gif\" 
border=0></a></td>\n";
                                echo "<td align=\"center\"><a 
href=\"proces.php?action=editart&articulo=$fila[0]\">
                                        <img src=\"../boletines/ima/editar.gif\" 
border=0></a></td>\n";
                                echo "</tr>\n";
                        }
                        echo "</table><br></p>";
        }
        else
        {
                        echo "<p>No Article exists associated to this 
Bulletin.<br><br></p>";
        }
     }
else
     {
        echo "<p>You have not entered a valid Bulletin Number, Verify the information 
and try again.</p>";
    }
}


-----  Translated by Rizwan Rizvi
[EMAIL PROTECTED]




Hi Marco,

Please use ENGLISH. This mailinglist is english.

Rolf

-----Oorspronkelijk bericht-----
Van: Marco A. Ortiz [mailto:[EMAIL PROTECTED]
Verzonden: zaterdag 31 januari 2004 16:45
Aan: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Onderwerp: RE: [PHP-DB] Problema con MySQL


Buenos d�as a todos:

Espero que alguno de ustedes hable espa�ol y me pueda ayudar a descubrir
qu�
est� mal en el siguiente c�digo:

El objetivo de la funci�n  es acceder a una base de Datos (MySQL) y
mostrar
los registros que cumplan cierta condici�n.  Si no existe ning�n
registro
que cumpla la condici�n, despliega un mensaje informa al usuario de la
situaci�n, de lo contrario, muestra en una tabla cada uno de los
registro
encontrados acompa�ados de las opciones �Eliminar� y �Editar�.

Por lo menos esto deber�a hacer. El problema es que no muestra el primero
de
los registros que cumplen la condici�n.  Le he dado mil vueltas y no he
logrado encontrar el error.

function mostrar_articulos_admin($boletin)
{
if (!$boletin == NULL)
       {
       $conn = db_connect();
                $query = "select id_articulo, titulo_articulo,
autor_articulo from articulo_boletin where id_boletin=$boletin";
                $result = mysql_query($query, $conn);
                $row = 0;
                $hay_arts = mysql_fetch_row ($result);
                if ($hay_arts)
                        {
                        echo "<h1>Art�culos correspondientes al Bolet�n
$boletin</h1>";
                                echo "<p>\n
                                        <table width=\"70%\"
align=\"center\" cellspacing=0>\n
                                        <tr>\n
                                                <td><b>Detalle
Art�culo</b></td>\n
                                                <td
align=\"center\"><b>Eliminar</b></td>\n
                                                <td
align=\"center\"><b>Editar</b></td>\n
                                        </tr>";
                                while ($fila = mysql_fetch_array($result,
MYSQL_NUM))
       {
                                                $row++;
                                                echo "<tr
bgcolor=\"".color_fila($row)."\">\n";
                                                echo
"<td><p><b>$fila[2]</b><br><i>$fila[3]</i></p></td>\n";
                                                echo "<td
align=\"center\"><a href=\"proces.php?action=delart&articulo=$fila[0]\">
                                                        <img
src=\"../boletines/ima/eliminar.gif\" border=0></a></td>\n";
                                                echo "<td
align=\"center\"><a
href=\"proces.php?action=editart&articulo=$fila[0]\">
                                                        <img
src=\"../boletines/ima/editar.gif\" border=0></a></td>\n";
                                                echo "</tr>\n";
                                        }
                                echo "</table><br></p>";
       }
                else
       {
                        echo "<p>No existe ning�n Art�culo asociado a este
Bolet�n.<br><br></p>";
                        }
        }
else
        {
                echo "<p>No ha indicado un n�mero de Boletin V�lido,
verifique la informaci�n e intente de nuevo.</p>";
        }
}

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to