<?php
session_start();
include('../db.php');

if (!session_is_registered("clave_audio")) {
	include("../login.php");
	if (!$continuar) exit;
}

if(isset($_REQUEST['op'])) {
	$op = $_REQUEST['op'];
} else {
	$op = "list";
}

// this code is for the "paginator"
$start = (isset($$_REQUEST['start']) ? $$_REQUEST['start'] : 0);
$limit = 25;
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>comentarios</title>
<link href="../sformi.css" rel="stylesheet" type="text/css">
</head>
<body>
<!-- CONTENT -->
<?php
	if($op == "edit"){
?>
	<table border="0" cellspacing="0" cellpadding="0">
		<tr><td><a href="comentarios_edit.php?op=add" class="button">[ add a new record ]</a></td></tr>
		<tr><td><img src="_imgs/d.gif" width="200" height="5"></td></tr>
	</table>

<?php
	}
?>

<table border="0" cellspacing="0" cellpadding="0">
<?php
//	include("../login.php");
//	if (!$continuar) exit;

	$conn = db_connect();
	if($conn) {
		$query = "SELECT comentario_articulo_id, comentario_articulo_id, comentario_autor_id, comentario_autor_name, comentario_texto, comentario_fecha FROM edito_comentarios ORDER BY comentario_articulo_id LIMIT " . $start . ",25";
		$result = mysql_query($query, $conn);
		$num_results = mysql_num_rows($result);
?>
	<tr>
		<td width="50" valign="top" class="hdr">Articulo Id</td><td width="50" valign="top" class="hdr">Autor Id</td><td width="150" valign="top" class="hdr">Autor Name</td><td width="400" valign="top" class="hdr">Texto</td><td width="80" valign="top" class="hdr">Fecha</td>
<?php
			// this buttons will always be after the data
	if($op == "edit"){
?>
		<td></td>
<?php
	}
?>
	</tr>
<?php
	for ($i=0; $i <$num_results; $i++)
	{
		$row = mysql_fetch_array($result);
		$comentario_articulo_id = $row['comentario_articulo_id'];
$comentario_articulo_id = $row['comentario_articulo_id'];
$comentario_autor_id = $row['comentario_autor_id'];
$comentario_autor_name = $row['comentario_autor_name'];
$comentario_texto = $row['comentario_texto'];
$comentario_fecha = $row['comentario_fecha'];

?>
	<tr>
			<td width="50" valign="top" class="data"><?php echo $comentario_articulo_id; ?></td><td width="50" valign="top" class="data"><?php echo $comentario_autor_id; ?></td><td width="150" valign="top" class="data"><?php echo $comentario_autor_name; ?></td><td width="400" valign="top" class="data"><?php echo $comentario_texto; ?></td><td width="80" valign="top" class="data"><?php echo $comentario_fecha; ?></td>
<?php
			// this buttons will always be after the data
		if($op == "edit"){
?>
			<td valign="top" class="data">&nbsp;<a href="comentarios_edit.php?op=edit&id=<?php echo $comentario_articulo_id; ?>" class="button">[ edit ]</a>&nbsp;&nbsp;<a href="comentarios_db.php?op=del&id=<?php echo $comentario_articulo_id; ?>" class="button">[ delete ]</a></td>
<?php
		}	
?>	
	</tr>
	<tr>
<?php
			if($op == "edit") {
?>
		<td bgcolor="#DBDEE6" colspan=6><img src="_imgs/d.gif" width="5" height="1"></td>
<?php
			} else {
?>
		<td bgcolor="#DBDEE6" colspan=5><img src="_imgs/d.gif" width="5" height="1"></td>
<?php
			}
?>
	</tr>
<?php
		}	// FOR
	} else {	// IF CONN
		echo '<p>An error has occurred while accessing the database: ' . mysql_error();
	}	 
?>
</table>
<?php
	// do we need to paginate the result?
	if($num_results > $limit) {
	
	}
?>
<!-- EOF CONTENT -->

<?php
	if($op == "edit"){
?>
	<table border="0" cellspacing="0" cellpadding="0">
		<tr><td></td></tr>
		<tr><td><img src="_imgs/d.gif" width="200" height="5"></td></tr>
	</table>

<?php
	}
?>
<!-- END OF CONTENT -->
</body>
</html>
