Jump to content

daniele

New Members
  • Posts

    5
  • Joined

  • Last visited

daniele's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. the var_dump by: int(0) string(1) "1"/ int(1) string(1) "2 the id part 1 with auto incremen
  2. the visibleMenu() method will return a false .I made a var_dump before the data and if there are var_dump($id,$visibol); if( empty($id) ) return false ; if ($visibol > 1) return false ; making a var_dump after nothing happens as if the data arrived
  3. in l'output I have the message by errore nel cambio dello stato error when changing the state that is in the swich
  4. 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
  5. Hello everyone I have a problem with an update I have created a menu and I have to make sure they can hide or show the menu I created three classes but does not work class 1 public function selectAction($action,$id){ switch($action){ case ('novisibol') : $visibol= 1; if( !$res=$this->_modelAdmin->visibleMenu($visibol,$id)){ echo 'errore nel cambio dello stato'; }else { header ('Location: admin.php?menu'); } break ; case ('visibol') : $visibol= 0 ; if( !$res=$this->_modelAdmin->visibleMenu($visibol,$id)){ echo 'errore nel cambio dello stato'; }else { header ('Location: admin.php?menu'); } Class 2 public function visibleMenu($id,$visibol){ if( empty($id) ) return false ; if ($visibol > 1) return false ; if ($visibol==0){ $this->_db->update( 'menu',array('menu_visibol'=>1),'menu_id='.$id ); }else { $this->_db->update( 'menu',array('menu_visibol'=>0),'menu_id='. $id ); } return true ; } Class 3 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 ); } thanks for the help and good holidays
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.