Ver Mensaje Individual
  #2  
Antiguo 06-07-2006
[kayetano] kayetano is offline
Miembro Premium
 
Registrado: may 2003
Ubicación: Elche
Posts: 644
Reputación: 22
kayetano Va por buen camino
Hola

No se por que te aparecen los ceros a la izquierda, a mi nunca me ha sucedido, pero te puedo dar algunos consejos:
1. Yo nunca he utilizado las comillas que pones en el nombre de todos los campos y tablas, desconozco su utilidad, yo lo haría de la siguiente forma:
Código PHP:
$result mysql_query("SELECT id, id_user, title, date FROM news"); 
2. Montas un lio enorme para hacer algo que ya lo hace PHP, con mysql_fetch_array:
Código PHP:
<?php
            
include(dbconf);
            
$query mysql_query("SELECT id, id_user, title, date FROM news");
            while( 
$result mysql_fetch_array$query ) ) {
                
$user mysql_result(mysql_query("SELECT `user` FROM `admin` WHERE `id` = ".$id_user), 0"user");                    
                echo 
"<tr>";
                echo 
"<td width='50'><input type='checkbox' name='del".$result['id']."' value='del".$result['id']."'>".$result['id']."</td>";
                echo 
"<td width='181'>".$result['title']."</td>";
                echo 
"<td width='75'>".$user."</td>";
                echo 
"<td width='85'>".$result['date']."</td>";
                echo 
"<td width='75'><input type='submit' name='ed".$result['id']."' value='Editar'></td>";
                echo 
"</tr>"
            }
?>
3. Las dos consultas que realizas se pueden hacer en una:
Código SQL [-]
SELECT n.id, n.id_user, n.title, n.date, a.user FROM news n, admin a WHERE n.id_user = a.id

4. y último, esto es mas por gusto que otra cosa y es no meter el código HTML dentro del PHP.

Código PHP:
<?php
            
include(dbconf);
            
$query mysql_query("SELECT n.id, n.id_user, n.title, n.date, a.user FROM news n, admin a WHERE n.id_user = a.id");
            while( 
$result mysql_fetch_array$query ) ) {
?>
                <tr>
                <td width='50'><input type='checkbox' name='del<?=$result['id']?>' value='del<?=$result['id']?>'><?=$result['id']?></td>
                <td width='181'><?=$result['title']?></td>";
                <td width='75'><?=$result['user?></td>
                <td width='
85'><?=$result['date']?></td>
                <td width='
75'><input type='submit' name='ed<?=$result['id']?> value='Editar'></td>";
                </tr>
<?
        
}    
?>
__________________
Salu2
KAYETANO

Cómo hacer preguntas de manera inteligente
Responder Con Cita