Ver Mensaje Individual
  #1 (permalink)  
Antiguo 08/04/2009, 19:06
Avatar de hoberwilly
hoberwilly
 
Fecha de Ingreso: julio-2008
Ubicación: Lima - Perú
Mensajes: 769
Antigüedad: 16 años, 8 meses
Puntos: 2
Crear array asociativo a partir de una consulta sql

Hola amigos, por favor tengo la siguiente consulta "Como crear un array asociativo" a partir de una sentencia sql

Necesito algo asi:
$notas=array{"luis"=>15,"maria"=>20,"pepe"=>10}

y este mi consulta sql:
Código php:
Ver original
  1. <table width="20%" border="1">
  2.       <tr>
  3.         <td>Nombre</td>
  4.         <td>Notas</td>
  5.       </tr>
  6.       <?php
  7.       $sql2="SELECT * FROM sesion WHERE idcurso=$curso";
  8.       $result2=mysql_query($sql2);
  9.       //$nombres=array();
  10.       //$notas=array();
  11.       while($row2=mysql_fetch_array($result2)){
  12.           //$nombres[]=$row2['nbralumno'];
  13.           //$notas[]=$row2['nota'];
  14.       ?>
  15.       <tr>
  16.         <td><?php echo $row2['nbralumno'] ?></td>
  17.         <td><?php echo $row2['nota'] ?></td>
  18.       </tr>
  19.       <?php
  20.       }
  21.       ?>
  22.     </table>

Agradesco de antemano la ayuda que me puedan brindar.