recoger una variable en campo de mysql - Foro Creativo

Ir a contenido


Página 1 de 1
  • No puedes empezar un nuevo tema
  • No puedes responder a este tema

recoger una variable en campo de mysql

#1 El usuario está offline   cartagines

  • Reciente
  • Grupo: Miembros
  • Mensajes: 8
  • Registrado: 19-junio 11
  • Gender:Male
  • Sexo:Masculino
  • País:Afghanistan
  • Navegador:Otro

Escrito 03 julio 2011 - 05:52

Hola
A ver si me podeis dar una orientacion sobre este asunto , ando algo pegado en programacion.
Tengo archivo flash *.swf que me para una serie de variables que recoge un archivo php y me las guarda en la base de datos:

guardar_datos.php

<?php
//Este es un script muy simple para ver las posibilidades de LIM y php

if (empty($_POST)){
//Si no recibe datos.
}else{
include('config.php');
$resul = $_POST['iresul'];
$titulo = $_POST['ititulo'];
$intime = $_POST['itime'];
$id = $_POST['iid'];
$user= $_POST['inom'];
//$user contiene la identificación del usuario, se debe obtener por sesión, cookie , etc, para este ejemplo utilizamos un valor fijo
//$user='$inom';
//$id es la identificación del libro-LIM, puede pasarse desde el propio libro mediante &id=...., o por código
if ($id!=''){
$conect=mysql_connect($dservidor, $duser, $dpass)or die ("");
if ($conect){
mysql_select_db ($base, $conect);
$sql = "SELECT * FROM  $tabla WHERE id_libro=".$id." AND usuario='".$user."';";
		$result = mysql_query($sql) or die (mysql_error());
		$nume = mysql_num_rows($result);
		if ($nume>0) {
$sql ="UPDATE $tabla SET id_libro='".$id."',libro='".$titulo."' ,datos='".$resul."',fecha=CURDATE() WHERE id_libro=".$id." AND usuario='".$user."';";
}
else{
$sql ="INSERT INTO $tabla ( `id_libro`, `usuario`, `libro`, `datos`, `fecha`) VALUES ('".$id."','".$user."','".$titulo."', '".$resul."', CURDATE());";
}
$result = mysql_query($sql)or die(mysql_error());

}
}
}
?>


Luego tengo otro archivo php que me visueliza esos datos:

ver_resultados.php

<?php require_once('../Connections/lim.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $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;
}
}

$maxRows_notas = 20;
$pageNum_notas = 0;
if (isset($_GET['pageNum_notas'])) {
  $pageNum_notas = $_GET['pageNum_notas'];
}
$startRow_notas = $pageNum_notas * $maxRows_notas;

mysql_select_db($database_lim, $lim);
$query_notas = "SELECT * FROM datos_lim ORDER BY usuario ASC";
$query_limit_notas = sprintf("%s LIMIT %d, %d", $query_notas, $startRow_notas, $maxRows_notas);
$notas = mysql_query($query_limit_notas, $lim) or die(mysql_error());
$row_notas = mysql_fetch_assoc($notas);

if (isset($_GET['totalRows_notas'])) {
  $totalRows_notas = $_GET['totalRows_notas'];
} else {
  $all_notas = mysql_query($query_notas);
  $totalRows_notas = mysql_num_rows($all_notas);
}
$totalPages_notas = ceil($totalRows_notas/$maxRows_notas)-1;$maxRows_notas = 20;
$pageNum_notas = 0;
if (isset($_GET['pageNum_notas'])) {
  $pageNum_notas = $_GET['pageNum_notas'];
}
$startRow_notas = $pageNum_notas * $maxRows_notas;

mysql_select_db($database_lim, $lim);
$query_notas = "SELECT * FROM datos_lim ORDER BY usuario DESC";
$query_limit_notas = sprintf("%s LIMIT %d, %d", $query_notas, $startRow_notas, $maxRows_notas);
$notas = mysql_query($query_limit_notas, $lim) or die(mysql_error());
$row_notas = mysql_fetch_assoc($notas);

if (isset($_GET['totalRows_notas'])) {
  $totalRows_notas = $_GET['totalRows_notas'];
} else {
  $all_notas = mysql_query($query_notas);
  $totalRows_notas = mysql_num_rows($all_notas);
}
$totalPages_notas = ceil($totalRows_notas/$maxRows_notas)-1;
?>
<!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=iso-8859-1" />
<title>Resultados</title>
<style type="text/css">
<!--
.cabecera {
	font-family: Georgia, "Times New Roman", Times, serif;
	font-size: 14px;
	font-weight: bold;
	background-color: #00CC66;
	background-position: center center;
	text-align: center;
}
.datos {
	font-family: Tahoma;
	font-size: 14px;
	font-weight: bold;
	text-align: center;
}
.final{
	font-family: Georgia, "Times New Roman", Times, serif;
	font-size: 20px;
	font-weight: bold;
}
-->
</style>
</head>

<body>
<?php
include('config.php');
$marcab='<img src="marcab.png"/>';
$marcam='<img src="marcam.png"/>';
$marcac='<img src="marcac.png"/>';
$suma=0;
$nump=0;
$num=0;
////Valores para este ejemplo, en un entorno real deben obtenerse de la sesión, post, get , etc
$id=2;
$user=$row_notas['usuario'];
print '<p class="final">Usuario: '.$user.'</p>';
?>
<table width="600" border="1" cellpadding="2" cellspacing="0">
  <tr class="cabecera">
    <td width="150">P&aacute;gina</td>
    <td width="150">Correcta</td>
    <td width="150">Intentos</div></td>
    <td width="150">No es un actividad </div></td>
  </tr>
  <p>
    <?php
if ($id!=''){
$conect=mysql_connect($dservidor, $duser, $dpass)or die ("");
if ($conect){
mysql_select_db ($base, $conect);
$sql = "SELECT * FROM  $tabla WHERE id_libro=".$id." AND usuario='".$user."';";
		$result = mysql_query($sql) or die (mysql_error());
		$nume = mysql_num_rows($result);
		if ($nume>0) {
while($fila = mysql_fetch_assoc($result)){
$titulo=$fila['titulo'];
$fecha=$fila['fecha'];
$resultado=explode(",",$fila[datos]);
$num=count($resultado)/4;
for ($f=0;$f<$num;$f++){
$nump++;
print ('<tr class="datos">');
print ("<td>".($f+1)."</td>");
 switch ($resultado[$m+2]){
 case "0":
print ("<td>".$marcac."</td>"); 
break;
case "1":
print ("<td>".$marcab."</td>"); 
$suma++;
break;
case "2":
print ("<td>".$marcam."</td>"); 
break;
default:
print ("<td></td>"); 
break;
}

 if ($resultado[$m+2]=="3"){
  print ("<td>----</td>"); 
 print ("<td>".$marcac."</td>"); 
 $nump--;
 }else{
  print ("<td>".$resultado[$m+3]."</td>"); 
 print ("<td></td>");
 }
 print ("</tr>");
 $m=$m+4;
 }

}
if ($suma>0){
$nota=number_format(($suma/$nump)*10,1);
}else{
$nota=0;
}
$texto='Fecha:'.$fecha.'<br>';
$texto=$texto."Correctas: ".$suma." de ".$nump." actividades"." ---- ";
$texto=$texto."Nota: ".$nota."";
print "</table>";
print ('<p class="final">'.$texto.'</p>');
}
}
}
  ?>
</p>
  <p>&nbsp;</p>
  <p>&nbsp;  </p>
<table border="1">
    <tr>
      <td>id</td>
      <td>id_libro</td>
      <td>usuario</td>
      <td>libro</td>
      <td>datos</td>
      <td>fecha</td>
       <td>nota</td>
       <td>resultado</td>
    </tr>
    <?php do { ?>
      <tr>
        <td><?php echo $row_notas['id']; ?></td>
        <td><?php echo $row_notas['id_libro']; ?></td>
        <td><?php echo $row_notas['usuario']; ?></td>
        <td><?php echo $row_notas['libro']; ?></td>
        <td><?php echo $row_notas['datos']; ?></td>
        <td><?php echo $row_notas['fecha']; ?></td>
        <td><?php echo  $nota; ?></td>
        <td><?php echo  $texto; ?></td>
      </tr>
      <?php } while ($row_notas = mysql_fetch_assoc($notas)); ?>
</table>
</body>
</html>
<?php
mysql_free_result($notas);
?>


Ahora bien, lo que pretendo es usar el script que me genera la variable notas y recogerla para insertarla en la base de datos a traves del archivo guardar_datos.php
Es decir integrar este fragmento de codigo:

<?php
include('config.php');
$marcab='<img src="marcab.png"/>';
$marcam='<img src="marcam.png"/>';
$marcac='<img src="marcac.png"/>';
$suma=0;
$nump=0;
$num=0;
////Valores para este ejemplo, en un entorno real deben obtenerse de la sesión, post, get , etc
$id=2;
$user=$row_notas['usuario'];
print '<p class="final">Usuario: '.$user.'</p>';
?>
<table width="600" border="1" cellpadding="2" cellspacing="0">
  <tr class="cabecera">
    <td width="150">P&aacute;gina</td>
    <td width="150">Correcta</td>
    <td width="150">Intentos</div></td>
    <td width="150">No es un actividad </div></td>
  </tr>
  <p>
    <?php
if ($id!=''){
$conect=mysql_connect($dservidor, $duser, $dpass)or die ("");
if ($conect){
mysql_select_db ($base, $conect);
$sql = "SELECT * FROM  $tabla WHERE id_libro=".$id." AND usuario='".$user."';";
		$result = mysql_query($sql) or die (mysql_error());
		$nume = mysql_num_rows($result);
		if ($nume>0) {
while($fila = mysql_fetch_assoc($result)){
$titulo=$fila['titulo'];
$fecha=$fila['fecha'];
$resultado=explode(",",$fila[datos]);
$num=count($resultado)/4;
for ($f=0;$f<$num;$f++){
$nump++;
print ('<tr class="datos">');
print ("<td>".($f+1)."</td>");
 switch ($resultado[$m+2]){
 case "0":
print ("<td>".$marcac."</td>"); 
break;
case "1":
print ("<td>".$marcab."</td>"); 
$suma++;
break;
case "2":
print ("<td>".$marcam."</td>"); 
break;
default:
print ("<td></td>"); 
break;
}

 if ($resultado[$m+2]=="3"){
  print ("<td>----</td>"); 
 print ("<td>".$marcac."</td>"); 
 $nump--;
 }else{
  print ("<td>".$resultado[$m+3]."</td>"); 
 print ("<td></td>");
 }
 print ("</tr>");
 $m=$m+4;
 }

}
if ($suma>0){
$nota=number_format(($suma/$nump)*10,1);
}else{
$nota=0;
}
$texto='Fecha:'.$fecha.'<br>';
$texto=$texto."Correctas: ".$suma." de ".$nump." actividades"." ---- ";
$texto=$texto."Nota: ".$nota."";
print "</table>";
print ('<p class="final">'.$texto.'</p>');
}
}
}
  ?>


Insertarlo en guardar_datos.php para que la nota se que quede guardada en la base de datos y asi poder jugar con ella.

Alguna orientacion por favor?
0


Página 1 de 1
  • No puedes empezar un nuevo tema
  • No puedes responder a este tema

Otras respuestas a este tema

#2 El usuario está offline   cartagines

  • Reciente
  • Grupo: Miembros
  • Mensajes: 8
  • Registrado: 19-junio 11
  • Gender:Male
  • Sexo:Masculino
  • País:Afghanistan
  • Navegador:Otro

Escrito 14 julio 2011 - 05:01

ok algo se ha enderezado el script, he conseguido recoger la variable nota e insertarla en el campo nota de mysql, ahora bien siempre me da el mismo resultado 0.0 y ha de darme la nota numerica, podeis revisar el script y comentarme alguna sujerencia?

El script es de la pagina guardar_datos.php

<?php
//Este es un script muy simple para ver las posibilidades de LIM y php

if (empty($_POST)){
//Si no recibe datos.
}
else
{
	include('config.php');
	$resul = $_POST['iresul'];
	$titulo = $_POST['ititulo'];
	$intime = $_POST['itime'];
	$id = $_POST['iid'];
	$user= $_POST['inom'];
	$nota = 0;
	
	//$user contiene la identificación del usuario, se debe obtener por sesión, cookie , etc, para este ejemplo utilizamos un valor fijo
	//$user='$inom';
	//$id es la identificación del libro-LIM, puede pasarse desde el propio libro mediante &id=...., o por código
	if ($id!='')
	{
		$conect=mysql_connect($dservidor, $duser, $dpass)or die ("");
		
		echo "conexion<br/>";
		
		if ($conect)
		{
			mysql_select_db ($base, $conect);
			$sql = "SELECT * FROM  $tabla WHERE id_libro=".$id." AND usuario='".$user."';";
					$result = mysql_query($sql) or die (mysql_error());
					$nume = mysql_num_rows($result);
					
					
					$arrayDatos=explode(",",$fila[datos]);
					$num=count($arrayDatos)/4;
					
					for ($f=0;$f<$num;$f++)
					{
						$nump++;
						
						switch ($resultado[$m+2])
						{
							case "1":
								$suma++;
								break;
							default:
								break;
						}

						if ($resultado[$m+2]=="3") $nump--;
						$m=$m+4;
					 }
					 
					 $nota=number_format(($suma/$nump)*10,1);
					
			if ($nume>0)
			{
				$sql ="UPDATE $tabla SET id_libro='".$id."',libro='".$titulo."', nota = '".$nota."', datos='".$resul."',fecha=CURDATE() WHERE id_libro=".$id." AND usuario='".$user."';";
			}
			else
			{
				$sql ="INSERT INTO $tabla ( `id_libro`, `usuario`, `libro`, `nota`, `datos`, `fecha`) VALUES ('".$id."','".$user."','".$titulo."','".$nota."', '".$resul."', CURDATE());" ;
			}

			$result = mysql_query($sql)or die(mysql_error());

			echo "$resul, $titulo, $intime, $id, $user, $nota";


		}
	}
}
?>


Graciassssssssssssss


Ver mensajecartagines, en 03 julio 2011 - 05:52 , dijo:

Hola
A ver si me podeis dar una orientacion sobre este asunto , ando algo pegado en programacion.
Tengo archivo flash *.swf que me para una serie de variables que recoge un archivo php y me las guarda en la base de datos:

guardar_datos.php

<?php
//Este es un script muy simple para ver las posibilidades de LIM y php

if (empty($_POST)){
//Si no recibe datos.
}else{
include('config.php');
$resul = $_POST['iresul'];
$titulo = $_POST['ititulo'];
$intime = $_POST['itime'];
$id = $_POST['iid'];
$user= $_POST['inom'];
//$user contiene la identificación del usuario, se debe obtener por sesión, cookie , etc, para este ejemplo utilizamos un valor fijo
//$user='$inom';
//$id es la identificación del libro-LIM, puede pasarse desde el propio libro mediante &id=...., o por código
if ($id!=''){
$conect=mysql_connect($dservidor, $duser, $dpass)or die ("");
if ($conect){
mysql_select_db ($base, $conect);
$sql = "SELECT * FROM  $tabla WHERE id_libro=".$id." AND usuario='".$user."';";
		$result = mysql_query($sql) or die (mysql_error());
		$nume = mysql_num_rows($result);
		if ($nume>0) {
$sql ="UPDATE $tabla SET id_libro='".$id."',libro='".$titulo."' ,datos='".$resul."',fecha=CURDATE() WHERE id_libro=".$id." AND usuario='".$user."';";
}
else{
$sql ="INSERT INTO $tabla ( `id_libro`, `usuario`, `libro`, `datos`, `fecha`) VALUES ('".$id."','".$user."','".$titulo."', '".$resul."', CURDATE());";
}
$result = mysql_query($sql)or die(mysql_error());

}
}
}
?>


Luego tengo otro archivo php que me visueliza esos datos:

ver_resultados.php

<?php require_once('../Connections/lim.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $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;
}
}

$maxRows_notas = 20;
$pageNum_notas = 0;
if (isset($_GET['pageNum_notas'])) {
  $pageNum_notas = $_GET['pageNum_notas'];
}
$startRow_notas = $pageNum_notas * $maxRows_notas;

mysql_select_db($database_lim, $lim);
$query_notas = "SELECT * FROM datos_lim ORDER BY usuario ASC";
$query_limit_notas = sprintf("%s LIMIT %d, %d", $query_notas, $startRow_notas, $maxRows_notas);
$notas = mysql_query($query_limit_notas, $lim) or die(mysql_error());
$row_notas = mysql_fetch_assoc($notas);

if (isset($_GET['totalRows_notas'])) {
  $totalRows_notas = $_GET['totalRows_notas'];
} else {
  $all_notas = mysql_query($query_notas);
  $totalRows_notas = mysql_num_rows($all_notas);
}
$totalPages_notas = ceil($totalRows_notas/$maxRows_notas)-1;$maxRows_notas = 20;
$pageNum_notas = 0;
if (isset($_GET['pageNum_notas'])) {
  $pageNum_notas = $_GET['pageNum_notas'];
}
$startRow_notas = $pageNum_notas * $maxRows_notas;

mysql_select_db($database_lim, $lim);
$query_notas = "SELECT * FROM datos_lim ORDER BY usuario DESC";
$query_limit_notas = sprintf("%s LIMIT %d, %d", $query_notas, $startRow_notas, $maxRows_notas);
$notas = mysql_query($query_limit_notas, $lim) or die(mysql_error());
$row_notas = mysql_fetch_assoc($notas);

if (isset($_GET['totalRows_notas'])) {
  $totalRows_notas = $_GET['totalRows_notas'];
} else {
  $all_notas = mysql_query($query_notas);
  $totalRows_notas = mysql_num_rows($all_notas);
}
$totalPages_notas = ceil($totalRows_notas/$maxRows_notas)-1;
?>
<!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=iso-8859-1" />
<title>Resultados</title>
<style type="text/css">
<!--
.cabecera {
	font-family: Georgia, "Times New Roman", Times, serif;
	font-size: 14px;
	font-weight: bold;
	background-color: #00CC66;
	background-position: center center;
	text-align: center;
}
.datos {
	font-family: Tahoma;
	font-size: 14px;
	font-weight: bold;
	text-align: center;
}
.final{
	font-family: Georgia, "Times New Roman", Times, serif;
	font-size: 20px;
	font-weight: bold;
}
-->
</style>
</head>

<body>
<?php
include('config.php');
$marcab='<img src="marcab.png"/>';
$marcam='<img src="marcam.png"/>';
$marcac='<img src="marcac.png"/>';
$suma=0;
$nump=0;
$num=0;
////Valores para este ejemplo, en un entorno real deben obtenerse de la sesión, post, get , etc
$id=2;
$user=$row_notas['usuario'];
print '<p class="final">Usuario: '.$user.'</p>';
?>
<table width="600" border="1" cellpadding="2" cellspacing="0">
  <tr class="cabecera">
    <td width="150">P&aacute;gina</td>
    <td width="150">Correcta</td>
    <td width="150">Intentos</div></td>
    <td width="150">No es un actividad </div></td>
  </tr>
  <p>
    <?php
if ($id!=''){
$conect=mysql_connect($dservidor, $duser, $dpass)or die ("");
if ($conect){
mysql_select_db ($base, $conect);
$sql = "SELECT * FROM  $tabla WHERE id_libro=".$id." AND usuario='".$user."';";
		$result = mysql_query($sql) or die (mysql_error());
		$nume = mysql_num_rows($result);
		if ($nume>0) {
while($fila = mysql_fetch_assoc($result)){
$titulo=$fila['titulo'];
$fecha=$fila['fecha'];
$resultado=explode(",",$fila[datos]);
$num=count($resultado)/4;
for ($f=0;$f<$num;$f++){
$nump++;
print ('<tr class="datos">');
print ("<td>".($f+1)."</td>");
 switch ($resultado[$m+2]){
 case "0":
print ("<td>".$marcac."</td>"); 
break;
case "1":
print ("<td>".$marcab."</td>"); 
$suma++;
break;
case "2":
print ("<td>".$marcam."</td>"); 
break;
default:
print ("<td></td>"); 
break;
}

 if ($resultado[$m+2]=="3"){
  print ("<td>----</td>"); 
 print ("<td>".$marcac."</td>"); 
 $nump--;
 }else{
  print ("<td>".$resultado[$m+3]."</td>"); 
 print ("<td></td>");
 }
 print ("</tr>");
 $m=$m+4;
 }

}
if ($suma>0){
$nota=number_format(($suma/$nump)*10,1);
}else{
$nota=0;
}
$texto='Fecha:'.$fecha.'<br>';
$texto=$texto."Correctas: ".$suma." de ".$nump." actividades"." ---- ";
$texto=$texto."Nota: ".$nota."";
print "</table>";
print ('<p class="final">'.$texto.'</p>');
}
}
}
  ?>
</p>
  <p>&nbsp;</p>
  <p>&nbsp;  </p>
<table border="1">
    <tr>
      <td>id</td>
      <td>id_libro</td>
      <td>usuario</td>
      <td>libro</td>
      <td>datos</td>
      <td>fecha</td>
       <td>nota</td>
       <td>resultado</td>
    </tr>
    <?php do { ?>
      <tr>
        <td><?php echo $row_notas['id']; ?></td>
        <td><?php echo $row_notas['id_libro']; ?></td>
        <td><?php echo $row_notas['usuario']; ?></td>
        <td><?php echo $row_notas['libro']; ?></td>
        <td><?php echo $row_notas['datos']; ?></td>
        <td><?php echo $row_notas['fecha']; ?></td>
        <td><?php echo  $nota; ?></td>
        <td><?php echo  $texto; ?></td>
      </tr>
      <?php } while ($row_notas = mysql_fetch_assoc($notas)); ?>
</table>
</body>
</html>
<?php
mysql_free_result($notas);
?>


Ahora bien, lo que pretendo es usar el script que me genera la variable notas y recogerla para insertarla en la base de datos a traves del archivo guardar_datos.php
Es decir integrar este fragmento de codigo:

<?php
include('config.php');
$marcab='<img src="marcab.png"/>';
$marcam='<img src="marcam.png"/>';
$marcac='<img src="marcac.png"/>';
$suma=0;
$nump=0;
$num=0;
////Valores para este ejemplo, en un entorno real deben obtenerse de la sesión, post, get , etc
$id=2;
$user=$row_notas['usuario'];
print '<p class="final">Usuario: '.$user.'</p>';
?>
<table width="600" border="1" cellpadding="2" cellspacing="0">
  <tr class="cabecera">
    <td width="150">P&aacute;gina</td>
    <td width="150">Correcta</td>
    <td width="150">Intentos</div></td>
    <td width="150">No es un actividad </div></td>
  </tr>
  <p>
    <?php
if ($id!=''){
$conect=mysql_connect($dservidor, $duser, $dpass)or die ("");
if ($conect){
mysql_select_db ($base, $conect);
$sql = "SELECT * FROM  $tabla WHERE id_libro=".$id." AND usuario='".$user."';";
		$result = mysql_query($sql) or die (mysql_error());
		$nume = mysql_num_rows($result);
		if ($nume>0) {
while($fila = mysql_fetch_assoc($result)){
$titulo=$fila['titulo'];
$fecha=$fila['fecha'];
$resultado=explode(",",$fila[datos]);
$num=count($resultado)/4;
for ($f=0;$f<$num;$f++){
$nump++;
print ('<tr class="datos">');
print ("<td>".($f+1)."</td>");
 switch ($resultado[$m+2]){
 case "0":
print ("<td>".$marcac."</td>"); 
break;
case "1":
print ("<td>".$marcab."</td>"); 
$suma++;
break;
case "2":
print ("<td>".$marcam."</td>"); 
break;
default:
print ("<td></td>"); 
break;
}

 if ($resultado[$m+2]=="3"){
  print ("<td>----</td>"); 
 print ("<td>".$marcac."</td>"); 
 $nump--;
 }else{
  print ("<td>".$resultado[$m+3]."</td>"); 
 print ("<td></td>");
 }
 print ("</tr>");
 $m=$m+4;
 }

}
if ($suma>0){
$nota=number_format(($suma/$nump)*10,1);
}else{
$nota=0;
}
$texto='Fecha:'.$fecha.'<br>';
$texto=$texto."Correctas: ".$suma." de ".$nump." actividades"." ---- ";
$texto=$texto."Nota: ".$nota."";
print "</table>";
print ('<p class="final">'.$texto.'</p>');
}
}
}
  ?>


Insertarlo en guardar_datos.php para que la nota se que quede guardada en la base de datos y asi poder jugar con ella.

Alguna orientacion por favor?

0

Página 1 de 1
  • No puedes empezar un nuevo tema
  • No puedes responder a este tema




Sitios Amigos: Tutoriales gratis | GuiaHosting | Foros de ComunidadHosting | Unidominios |