La cosa es que esa parte es fácil, pero tamién quería crear un archivo mediante el cual pueda administrar las cateorias (y otro los articulos), sin embargo, consigo seleccionar las categorias y mostrarlas en localhost, pero no en mi sitio web
Tampoco consigo ni en localhost ni en mi sitio web. hacer para "editarlas", y a eliminarlas por ejemplo, ni he llegado XD
El código del archivo que gestiona las categorias es este
Código PHP:
Me muestra los siguientes erroresVer original
<html> <head> <link href="/onfire/css/bootstrap.css" rel="stylesheet"> <style type="text/css"> body { padding-top: 60px; padding-bottom: 40px; } .sidebar-nav { padding: 9px 0; } @media (max-width: 980px) { /* Enable use of floated navbar text */ .navbar-text.pull-right { float: none; padding-left: 5px; padding-right: 5px; } } </style> </head> <body> <?php include ('/../config.php'); include ('/../functions.php'); { //If not isset -> set with dumy value $_GET['action'] = "view"; } $action = $_GET['action']; switch($action) { case 'view': ?> <table class="table table-striped"> <thead> <tr> <th>ID</th> <th>Name</th> <th>Type</th> <th>Status</th> </tr> </thead> <tbody> <?php $sql = "SELECT * from category"; echo ' <tr> <td> '.$row["id"].'</td> <td> '.$row["name"].'</td> <td> '.$row["type"].' </td> <td> '.$row["status"].' </td> <td><a href="category.php?action=edit&id='.$row["id"].'"><button class="btn btn-mini btn-success" type="button">Editar</button></a></td> <td><a href="category.php?action=delete&id='.$row["id"].'"><button class="btn btn-mini btn-danger" type="button">Eliminar</button></a></td> </tr>'; } ?> </tbody> </table> <a href="category.php?action=add"><button class="btn btn-mini btn-info" type="button">Añadir</button></a> <?php break; case 'add': ?> <form method="post" action="category.php?action=add&add=cat"> Nombre: <input type="text" class="input-medium" name="name" placeholder="Nombre de la categoria" /> <br/><br/> Tipo: <input type="text" class="input-large" name="type" placeholder="Tipo de articulo (0 o 1)"/> <br /><br/> Estado: <input type="text" class="input-large" name="status" placeholder="Tipo de categoria (0 o 1)"/> <br /><br/> <input type="submit" value="Enviar" class="btn" /> </form> <?php if ($_GET["add"] == "cat"){ $name = $_POST['name']; $type = $_POST['type']; $status = $_POST['status']; $sql = "INSERT INTO `category` (`name`,`type`,`status`) VALUES ('$name','$type','$status');"; if ($result){ echo 'Categoria creada con éxito, haz <a href="category.php?action=view">clic aqui</a> para volver atrás '; } } break; case 'edit': $id = $_GET['id']; $sql = "SELECT * from category WHERE id='".$id."' "; $rowid = $row['id']; $name = $row['name']; $status = $row['status']; $type = $row['type']; echo '<form method="post" action="category.php?action=update&mode=edit"> <input type="hidden" name="id" value="$id" /> Nombre: <input type="text" class="input-medium" name="name" value="$name" /> <br/><br/> Tipo: <input type="text" class="input-large" name="type" value="$type"/> <br /><br/> Estado: <input type="text" class="input-large" name="status" value="$status"/> <br /><br/> <input type="submit" value="Enviar" class="btn" /> </form>'; } break; case 'delete': echo $action; break; case 'update': echo $action; break; } ?> </body> </html>
Warning: mysqli_query() expects parameter 1 to be mysqli, null given
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given
Warning: mysqli_error() expects exactly 1 parameter, 0 given
Mientras que en localhost, en el edit me da este error
Warning: mysql_fetch_array() expects parameter 1 to be resource, object given
¿Que sucede, algun consejo, etc?
PD: El config.php esta en otro directorio, y este hecho de forma en q pasa por la variable $con todos los par