English Translation of "Problema con MySQL
| From: | Rizwan Rizvi | Date: | Tue, 03 Feb 2004 19:29:24 +0000 |
| Subject: | English Translation of "Problema con MySQL | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-32768@lists.php.net to get a copy of this message | ||
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
rrizvi@un.org.mx
Hi Marco,
Please use ENGLISH. This mailinglist is english.
Rolf
-----Oorspronkelijk bericht-----
Van: Marco A. Ortiz [mailto:aortizma@unal.edu.co]
Verzonden: zaterdag 31 januari 2004 16:45
Aan: php-db@lists.php.net; php-evangelism@lists.php.net
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>";
}
}