Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Yuri Oliveira

Problema ao retorna valor do banco.

Recommended Posts

Olá,

 

Estou com um problema ao retorna minhas notas do banco de dados.

Queria retorna las para o campo em branco da tabela, o que eu poderia fazer?

 

 

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Untitled Document</title>

</head>

 

<body>

 

<form method="post" action= "<?php echo $_SERVER['PHP_SELF']; ?>">

<p> 

<table cellspacing="0" cellpadding="0" border="1" align="center">

<col width="29" />

<col width="329" />

<col width="166" />

<col width="90" />

<tr height="100px">

<td scope="col" colspan="5" height="60px" align="center">

<img src="../imagens/ideia.jpg" width="224" height="60" alt="Instituto IDEIA" title="http://www.ideiaeduc.com.br/" style="margin-bottom:12px;"/>

           

<img src="../imagens/ua.jpg" width="130" height="83" alt="Universidad Americana" style="margin-top:5px;" />

</td>

</tr>

<tr>

<td colspan="4" width="614" align="center">PLANILHA DE NOTAS</td>

</tr>

<tr>

<td colspan="4">DOCTORADO EN ADMINISTRACIÓN: DA 1.1/12 – JULHO 2012</td>

</tr>

<tr>

<td colspan="4">ASIGNATURA: <select id="materia" name="materia" size="1" class="styled" />

<option value="">-Selecione-</option>

<option value="Contabilidade de Gestión">Contabilidade de Gestión</option>

<option value="Gestión de Personas y Relaciones Laborales">Gestión de Personas y Relaciones Laborales</option>

<option value="Teoria de los Modelos de Organización">Teoria de los Modelos de Organización</option>

</select>

</td>

</tr>

<tr>

<td colspan="4">PROFESOR: Gustavo Adolfo Valenzuela Ferreira </td>

</tr>

<tr>

<td width="29">Nº</td>

<td width="329">Apellidos y Nombres (completos)</td>

<td width="166">Cedula Identidad</td>

<td width="90">Nota Final</td>

</tr>

<tr>

<td width="29">1</td>

<td>RICARDO DE BONIS</td>

<td>14087</td>

<td><?php echo $nota1; ?></td>

</tr>

<tr>

<td width="29">2</td>

<td>MARIA DE FÁTIMA B. SILVA</td>

<td>0856421421</td>

<td><?php echo $nota2; ?></td>

</tr>

<tr>

<td width="29">3</td>

<td>ANISIA DARC DO N. BRAHIM</td>

<td>063849699</td>

<td><?php echo $nota3; ?></td>

</tr>

</table>

<p align="center">Caso a nota não esteja cadastrada <a href="da.1.1.12.php"> clique aqui</a></p>

<p align="center">

<input type = "button" value = "voltar" name = "cancelar" onclick="javascript:history.back(1)" />

</p>

 

 

<?php

//conecta-se ao banco de dados

$dbc = mysqli_connect('localhost','root','','planilha_de_notas') or die( mysqli_error());

 

//Obtem os dados dos alunos

$query = "SELECT * FROM da1112";

$result = mysqli_query($dbc, $query) or die (mysqsl_error());;

 

while ($row = mysql_fetch_array($result)) {

$nota1 = $linha["nota1"];

$nota2 = $linha["nota2"];

$nota3 = $linha["nota3"];

 

}

 

 

 

mysqli_close($dbc);

 

?>

 

 

 

</body>

</html>

 

esqueci de mencionar os erros que aparecem.

 

 

Warning: mysql_fetch_array() expects parameter 1 to be resource, object given in C:\Program Files\EasyPHP-12.1\www\planilha_de_notas\Gustavo Adolfo\turma\mostra_nota.php on line 18

 

 

e dentro de cada campo de nota aparece o erro:

 

Notice: Undefined variable: nota1 in C:\Program Files\EasyPHP-12.1\www\planilha_de_notas\Gustavo Adolfo\turma\mostra_nota.php on line 75

 

 

Notice: Undefined variable: nota1 in C:\Program Files\EasyPHP-12.1\www\planilha_de_notas\Gustavo Adolfo\turma\mostra_nota.php on line 81

 

 

Notice: Undefined variable: nota1 in C:\Program Files\EasyPHP-12.1\www\planilha_de_notas\Gustavo Adolfo\turma\mostra_nota.php on line 87

Compartilhar este post


Link para o post
Compartilhar em outros sites

Penso que o mais correto seria fazer algo como abaixo:

 

<td width="29">Nº</td>
<td width="329">Apellidos y Nombres (completos)</td>
<td width="166">Cedula Identidad</td>
<td width="90">Nota Final</td>
</tr>
<?php
//conecta-se ao banco de dados
//$dbc = mysqli_connect('localhost','root','','planilha_de_notas') or die( mysqli_error());

//Obtem os dados dos alunos
//$query = "SELECT * FROM da1112";
//$result = mysqli_query($dbc, $query) or die (mysqsl_error());;

while ($linha = mysql_fetch_array($result)) {
$nota =$linha["nota"];
$cedula =$linha["campocedula"];
$nome=$linha["camponome"];
echo'
<td width="29">1</td>
<td>'.$nome.'</td>
<td>'.$cedula.'</td>
<td>'.$nota.'</td>
</tr>
</table>
';
}
mysqli_close($dbc);

?>

<p align="center">Caso a nota não esteja cadastrada <a href="da.1.1.12.php"> clique aqui</a></p>
<p align="center">
<input type = "button" value = "voltar" name = "cancelar" onclick="javascript:history.back(1)" />
</p>

Compartilhar este post


Link para o post
Compartilhar em outros sites
Estou com um problema ao retorna minhas notas do banco de dados.

mensagens de erro são claras; variaveis não declaradas..

preste atenção nesse trecho:

 

while ($row = mysql_fetch_array($result)) {
$nota1 = $linha["nota1"];
$nota2 = $linha["nota2"];
$nota3 = $linha["nota3"];

tente trocar $linha por $row..

Compartilhar este post


Link para o post
Compartilhar em outros sites

eu consegui de um jeito, não sei se é o certo rs

mas pelo menos deu certo como eu queria.

se souberem um jeito melhor e mais limpo irei agradecer mutio.

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Untitled Document</title>

</head>

 

<body>

 

 

 

<form method="post" action= "<?php echo $_SERVER['PHP_SELF']; ?>">

<p> 

<table cellspacing="0" cellpadding="0" border="1" align="center">

<col width="29" />

<col width="329" />

<col width="166" />

<col width="90" />

<tr height="100px">

<td scope="col" colspan="5" height="60px" align="center">

<img src="../imagens/ideia.jpg" width="224" height="60" alt="Instituto IDEIA" title="http://www.ideiaeduc.com.br/" style="margin-bottom:12px;"/>

           

<img src="../imagens/ua.jpg" width="130" height="83" alt="Universidad Americana" style="margin-top:5px;" />

</td>

</tr>

<tr>

<td colspan="4" width="614" align="center">PLANILHA DE NOTAS</td>

</tr>

<tr>

<td colspan="4">DOCTORADO EN ADMINISTRACIÓN: DA 1.1/12 – JULHO 2012</td>

</tr>

<tr>

<td colspan="4">ASIGNATURA:

CONTABILIDADE GERENCIALl</td>

</tr>

<tr>

<td colspan="4">PROFESOR: Gustavo Adolfo Valenzuela Ferreira </td>

</tr>

<tr>

<td width="29">Nº</td>

<td width="329">Apellidos y Nombres (completos)</td>

<td width="166">Cedula Identidad</td>

<td width="90">Nota Final</td>

</tr>

<tr>

<td width="29">1</td>

<td>RICARDO DE BONIS</td>

<td>14087</td>

<td><?php

//conecta-se ao banco de dados

$dbc = mysqli_connect('localhost','root','','planilha_de_notas') or die( mysqli_error());

 

//Obtem os dados dos alunos

$query = "SELECT * FROM da1112";

$result = mysqli_query($dbc, $query) or die or die (mysqli_error());

 

 

 

while ($row = mysqli_fetch_array($result)) {

 

 

 

echo $row['nota1'].'<br>';

 

}

 

 

 

mysqli_close($dbc);

 

?></td>

</tr>

<tr>

<td width="29">2</td>

<td>MARIA DE FÁTIMA B. SILVA</td>

<td>0856421421</td>

<td><?php

//conecta-se ao banco de dados

$dbc = mysqli_connect('localhost','root','','planilha_de_notas') or die( mysqli_error());

 

//Obtem os dados dos alunos

$query = "SELECT * FROM da1112";

$result = mysqli_query($dbc, $query) or die or die (mysqli_error());

 

 

 

while ($row = mysqli_fetch_array($result)) {

 

 

echo $row['nota2'].'<br>';

 

}

 

 

 

mysqli_close($dbc);

 

?></td>

</tr>

<tr>

<td width="29">3</td>

<td>ANISIA DARC DO N. BRAHIM</td>

<td>063849699</td>

<td><?php

//conecta-se ao banco de dados

$dbc = mysqli_connect('localhost','root','','planilha_de_notas') or die( mysqli_error());

 

//Obtem os dados dos alunos

$query = "SELECT * FROM da1112";

$result = mysqli_query($dbc, $query) or die or die (mysqli_error());

 

 

 

while ($row = mysqli_fetch_array($result)) {

 

 

echo $row['nota3'];

}

 

 

 

mysqli_close($dbc);

 

?></td>

</tr>

</table>

<p align="center">Caso a nota não esteja cadastrada <a href="da.1.1.12.php"> clique aqui</a></p>

<p align="center">

<input type = "button" value = "VOLTAR" name = "cancelar" onclick="javascript:history.back(1)" />

</p>

 

 

</body>

</html>

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.