} } if(isset($_POST["word"])) { $word = new Mot($_POST["word"]); echo $word->create(); } if(isset($_GET["id"])) { $word = new Mot("",$_GET["id"]); echo $word->delete(); } $req = "SELECT * FROM words"; $result = mysql_query($req, $cnx); ?> <ul> <?php while($item = mysql_fetch_array($result)) { $word = new Mot($item["word"],$item["id"]); echo $word->read(); } ?> </ul> <form method="post" action="<?=$_SERVER["PHP_SELF"]?>"> <h2>Ajouter un mot</h2> <input type="text" name="word"> <input type="submit" value="ajouter"> </form> <a href="index.html">Accès au jeu</a>
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = Mot::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'El enlace o direccion solicitado no existe'); } return $model; }