[Resolvido] While não mostra 1º registro na consulta
Bom Dia
Preciso efetuar multiplos inserts numa tabela, pesquisei e adaptei um código que achei na net, porem ele não mostra sempre o primeiro registro da consulta, já fiz várias alterações e nada, será que alguém poderia me dar uma luz.
<?php require_once('../Connections/conexao.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$colname_consulta = "-1";
if (isset($_GET['serieID'])) {
$colname_consulta = (get_magic_quotes_gpc()) ? $_GET['serieID'] : addslashes($_GET['serieID']);
}
mysql_select_db($database_conexao, $conexao);
$query_consulta = sprintf("SELECT matricula.matriculaID, alunos.aluno FROM matricula, alunos WHERE matricula.serieID = %s AND matricula.alunoID = alunos.alunoID ORDER BY alunos.aluno", GetSQLValueString($colname_consulta, "int"));
$consulta = mysql_query($query_consulta, $conexao) or die(mysql_error());
$row_consulta = mysql_fetch_assoc($consulta);
$totalRows_consulta = mysql_num_rows($consulta);
?>
<form name='teste' method='post' action='teste2.php'>
<?php
$x = 0;
while ($row = mysql_fetch_array($consulta)){
$matricula = $row['matriculaID'];
$aluno = $row['aluno'];
$nota = "Digite a nota";
?>
<table>
<tr>
<td> <input type=text name="matricula[$x]" value="<?php echo $matricula; ?>"></td>
<td> <input type="text" name="aluno[$x]" value="<?php echo $aluno; ?>"></td>
<td> <input type="text" name="nota[$x]" value="<?php echo $nota ?>"></td></tr>
<?php
$x++;
}?>
<tr><td><input type=submit></td></tr>
</table>
</form>
<?php
mysql_free_result($consulta);
?>
Obrigado
Discussão (2)
Carregando comentários...