the script does not give me error simply does not do what I want.
The third class and so full:
class DbConn { private $_conn=''; public function __construct(){ $this->_conn=mysqli_connect('localhost','root','','sito'); if($this->_conn->errno){ echo "errore di conessione".$this->_conn->error; } } public function select( $fields, $tables, $conditions = '1' ){ $query = "SELECT "; $query .= implode( ', ', $fields ); $query .= " FROM "; $query .= implode( ', ', $tables ); $query .= " WHERE "; $query .= $conditions; error_log(var_export($query,true)); return mysqli_query( $this->_conn, $query ); } public function update( $table, $values, $conditions = '1' ){ $first = true; $query = "UPDATE " . $table; $query .= " SET "; foreach( $values as $name => $value ){ if( ! $first ){ $query .= ", "; } $query .= $name . " = " . $value; $first = false; } $query .= " WHERE "; $query .= $conditions; return mysqli_query( $this->_conn, $query ); } public function delete( $table, $conditions = '0' ){ $query = "DELETE FROM " . $table; $query .= " WHERE "; $query .= $conditions; return mysqli_query( $this->_conn, $query ); } public function fetch_assoc($res) { return mysqli_fetch_assoc($res); } public function escape($string) { return mysqli_escape_string($this->_conn, $string); } public function __destruct() { $this->_conn->close(); } }
if you can help you put also the view
<?php require_once ($_SERVER['DOCUMENT_ROOT']."/controllers/controller_admin.php"); require_once ($_SERVER['DOCUMENT_ROOT']."/modules/module_admin.php"); require_once($_SERVER['DOCUMENT_ROOT']."/libreria/DbConn.php"); $action = (isset($_GET['action'])) ? $_GET['action'] : null ; $id = (isset($_GET['id'])) ? $_GET['id'] : null ; $controllerAdmin=new controller_admin($action,$id); $result=$controllerAdmin->menuAdmin(); ?> <?php if(!empty($result)): ?> <h2>gestione menu</h2> <table> <thead> <tr> <th>nome Categoria</th> <th>Visibilita</th> <th colspan="2">Modifica</th> </tr> </thead> <?php foreach ($result as $risultato): ?> <?php if($risultato['menu_visibol']== 1){ $action="?menu&action=novisibol"; $text="novisibol"; $class="novisibol"; } else{ $action="?menu&action=visibol"; $text="visibol"; $class="visibol"; } ?> <tr> <td><a href="?menu&action=edit&id=<?php echo $risultato['menu_id']; ?>" title="<?php echo $risultato['menu_title']; ?>"><?php echo $risultato['menu_name'] ; ?></a> </td> <td><a title="<?php echo $text ;?>" class="<?php echo $class ; ?>" href="<?php echo $action . '&id='.$risultato['menu_id']; ?>"><?php echo $text ;?></a> </td> <td><a href="?menu&action=edit&id=<?php echo $risultato['menu_id']; ?>" title="modifica">Modifica</a></td> <td><a href="?menu&action=delete&id=<?php echo $risultato['menu_id']; ?>" title="elimina">Elimina</a></td> </tr> <?php endforeach ; ?> </table> <?php endif ;?>
thanks for the help