Código PHP:
//////////////////////////////////////////////////////////////////////////////////
// -------------------- LISTAR POSTS PA EDITAR O BORRAR -------------------
//////////////////////////////////////////////////////////////////////////////////
elseif($_GET["editpost"] == 'listar') {
echo"<h3>Listado de Articulos</h3>";
/*
* Selector de post por categorias
*/
echo "<form name='select_post_type' id='select_post_type' action='posts2.php' method='get'>
<select name='post_category' id='post_category'>
<option selected='selected' value=''>Todas las categorias</option>";
//selecciono de las tablas
$categ = mysql_query("SELECT * FROM categorias", $connect_db);
//Listo las categorias a traves de un array
while($myrow=mysql_fetch_array($categ)) {
echo "<option value=".$myrow[cat_ID].">".$myrow[cat_nombre]."</option>";
}
echo "</select><input type='hidden' name='editpost' value='listar' />
<button type='submit' value='Seleccionar' class='btn'><i class='icon-search'></i></button></form>
<!-- Inicio de la tabla -->
<p>Categoria:".$catactual."</p>
<table class='table table-striped table-bordered table-condensed'>
<thead>
<tr>
<th>#</th>
<th>Titulo</th>
<th>Fecha</th>
<th>Autor</th>
<th>Acciones</th>
</tr>
</thead>
<tbody>
<tr>
</tr>";
if ($_GET["post_category"]>0){
$post_listar=mysql_query("SELECT * FROM posts WHERE post_category=".$_GET["post_category"]." ORDER BY ID DESC", $connect_db);
$catactual = $_GET["post_category"];
}else{
$post_listar = mysql_query("SELECT * FROM posts ORDER BY ID DESC", $connect_db);
}
//Listo todos los posts
while($myrow=mysql_fetch_array($post_listar))
{
$cnt++;
if(file_exists("../img_posts/$myrow[ID].jpg")){
$html_img = "<div class='imgthmb'><img src='../img_posts/$myrow[ID].jpg' width='100%' /></div><br />";
}else{
$html_img = '';
}
$valrec=substr($myrow[post_content], 0, 320);
$val = str_replace(chr(13), "<br />\n", $valrec);
echo "<tr>
<td>".$myrow[ID]."</td>
<td><a href=./posts.php?ID=".$myrow[ID].">".$myrow[post_title]."</a></td>
<td>".$myrow[post_date]."</td>
<td>".$myrow[post_autor]."</td>
<td class='td-actions'>
<a href='./posts2.php?editpost=edit&ID=$myrow[ID]' class='btn btn-small'>
<i class='btn-icon-only icon-edit'></i>
</a>
<a data-original-title='Remove' href='super8_imgupld.php?ID=".$myrow[ID]."&imgpath=post' data-toggle='modal' class='btn btn-small'>
<i class='btn-icon-only icon-camera'></i>
</a>
<a data-original-title='Remove' href='#Alert' data-toggle='modal' class='btn btn-small btn-danger'>
<i class='btn-icon-only icon-trash''></i>
</a>
<!-- Modal: Alert -->
<div class='modal hide fade' id='Alert'>
<div class='modal-header'>
<button type='button' class='close' data-dismiss='modal'>×</button>
<h3>Estas seguro?</h3>
</div>
<div class='modal-body'>
<p>Vas a eliminar el articulo: ".$myrow[ID].", quieres eliminarlo?</p>
</div>
<div class='modal-footer'>
<a href='#' class='btn' data-dismiss='modal'>No</a>
<a href='./posts2.php?editpost=del&ID=$myrow[ID]' class='btn btn-primary'>Si</a>
</div>
</div>
<!-- Fin de Modal: Alert -->
</td>";
}
echo "</tr></tbody></table>";