Ver Mensaje Individual
  #3 (permalink)  
Antiguo 14/03/2011, 12:27
programadorNovato
 
Fecha de Ingreso: marzo-2010
Ubicación: Guadalajara, Jal
Mensajes: 91
Antigüedad: 14 años, 2 meses
Puntos: 1
Respuesta: Ayuda mysql_query() no recuerda su valor.

Cita:
Iniciado por tonysanrusso Ver Mensaje
Hola,
Tengo un problema para listas los datos de una tabla artistas de la bd galeria.
El problema es que cuando llega el código al while($row=mysql_fetch_assoc($recordset)){ el RECORSET ya no tiene valor, nosé porque sucede esto.
Lo digo porque después del $recordset = mysql_query($sql); coloqué un mysql_affect_rows() y me devolvió los valores encontrados en la tabla, mientras que cuando lo puse arriba del WHILE, no recuerda su valor, sale a 0 o false.
Helpp.
Gracias.

Código PHP:
<?php
$link 
mysql_connect("localhost""root");
if(
mysql_select_db("galeria")){
   echo 
"Conectado correctamente a galeria";    
}else
    echo 
"no estas conectado a ninguna bd";

extract($_REQUEST);
if( isset(
$action) && $action="delete" ) {
    
$sql "DELETE FROM Artist WHERE id='$id'";
    
mysql_query($sql);
}


?>  


<h1>Artist List</h1>

<table cellpadding="5">
<th>Artist</th><th>Phone</th><th>Email</th><th>Action</th>

<?

$sql 
"SELECT * FROM artist ORDER BY name";
$recordset mysql_query($sql);

    while(
$row=mysql_fetch_assoc($recordset)){
    
    print 
'<tr>
        <td><a href="admin_artist_edit.php?id='
$row["id"]. '">' .$row["name"] .'</a></td>' .
           
"<td>"$row["phone"] ."</td>
           <td>"
$row["email"] ."</td>".
        
'<td><a href="admin_artist_list.php?action=delete&id='$row["id"]."\">Delete</a></td></tr>\n";

    }

?>

</table>



Reescribe esta parte

<h1>Artist List</h1>

<table cellpadding="5">
<th>Artist</th><th>Phone</th><th>Email</th><th>Action</th>

<?

$sql = "SELECT * FROM artist ORDER BY name";
$recordset = mysql_query($sql);

while($row=mysql_fetch_assoc($recordset)){


lo demás...
__________________
Si me pides ayuda ten por seguro que hare todo mi esfuerzo por ayudarte...