Ver Mensaje Individual
  #6 (permalink)  
Antiguo 26/05/2011, 03:39
Avatar de s00rk
s00rk
 
Fecha de Ingreso: octubre-2010
Ubicación: Mexico
Mensajes: 238
Antigüedad: 13 años, 6 meses
Puntos: 48
Respuesta: Problema con consulta mysql

No lo cheque del todo pero espero asi te sirva mira:

Código PHP:
<?php
require('conexion.php');

$busqueda $_POST['busqueda'];
$busca "SELECT * FROM alumnos WHERE id_alumno = '".$busqueda."'";

?>
    <table style="width:20%;" border="1px">
    <tbody>
        <tr>
            <td class="id_asig">ASIGNATURA</td>
            <td class="nota">NOTA</td>


        </tr>
<?php

$r 
mysql_query($busca);
$i 0;
$x = array();
while (
$row mysql_fetch_assoc($r))
{
    echo 
$row['nombre']."\t";
    echo 
$row['apellido']."<br>";
    if(!
array_search($row['id_asig'],$x))
    {
        
$x[$i] = $row['id_asig'];
        
$i++;
    }
}

for(
$ii 0$ii $i$ii++)
{
    
$r mysql_query("SELECT * FROM alumnos WHERE id_alumno='".$busqueda."' AND id_asig='".$x[$ii]."'");
    echo 
'<tr><td class="id_asig">'.$x[$ii].'</td>';
    while (
$row mysql_fetch_assoc($r))
    {
        echo 
'<td class="nota">'.$row['nota'].'</td>';
    }
    echo 
'</tr>';
}

?>