<?php class requetes extends PDO{ private $dbh; public function __construct($dsn,$username=null,$password,$options=null){ $this->dbh = parent::__construct($dsn,$username,$password,$options); } public function selectUnProjet($id){ //echo $id; $sql = "SELECT * FROM eleve WHERE ideleve='".$id."'"; try { $stmt = $this->query($sql); $result = $stmt->setFetchMode(PDO::FETCH_NUM); while ($row = $stmt->fetch()) { print $row[0] . "\t" . $row[1] . "\t" . $row[2] . "\n"; } } catch (PDOException $e) { print $e->getMessage(); } /* $resultats = $this->query("SELECT * FROM eleve WHERE id='".$id."'"); $this->$resultats->setFetchMode(PDO::FETCH_OBJ); while($ligne = $resultats->fetch()) { echo "allo". $return = $this->cleanRow($ligne); } $result->free(); //echo $return; return $return; */ } } $options array(PDO::MYSQL_ATTR_INIT_COMMAND> "SET NAMES utf8"); $req = new requetes('mysql:host=localhost;dbname=test','root','',$options); $section = $req->selectUnProjet($_GET['noProjet']=1); ?>
<?php /*du code ...*/ include(mesclass/classrequete.php); $options array(PDO::MYSQL_ATTR_INIT_COMMAND> "SET NAMES utf8"); $req = new requetes('mysql:host=localhost;dbname=test','root','',$options); $section = $req->selectUnProjet($_GET['noProjet']=1); echo ''; print_r($section); /*si tu retournes un array avec le return de la methode selectUnProjet */ echo ' '; /* ... du code*/ ?>
class requetes extends PDO{ public function __construct($dsn,$username=null,$password=null, $driver_options=null){ parent::__construct($dsn, $username, $password, $driver); } ...
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question<?php class requetes extends PDO { public function __construct($dsn,$username=null,$password,$options=null){ parent::__construct($dsn,$username,$password,$options); } public function selectUnProjet($id){ echo $id; /* $resultats= $db->query("SELECT * FROM WHERE No=".$id); $resultats->setFetchMode(PDO::FETCH_OBJ); while($ligne = $resultats->fetch()) { echo "allo". $return = $this->cleanRow($ligne); } $result->free(); echo $return; return $return; */ } } $options array(PDO::MYSQL_ATTR_INIT_COMMAND> "SET NAMES utf8"); $req = new requetes('mysql:host=localhost;dbname=test','root','',$options); $section = $req->selectUnProjet($_GET['noProjet']=5551); ?>
$section = $req->selectUnProjet($_GET['noProjet']);
class requetes { function selectUnProjet($id) { $resultats= $db->query("SELECT * FROM projets WHERE No=".$id); $resultats->setFetchMode(PDO::FETCH_OBJ); while($ligne = $resultats->fetch()) { $return = $this->cleanRow($ligne); } $result->free(); echo $return; return $return; } }
value="<?php echo $section['titre']; ?>"
public function selectUnProjet($id) { $sql = "SELECT * FROM projets WHERE No='".$id."'"; try { $stmt = $this->query($sql); while ($row = $stmt->fetch()) { $return = $this->cleanRow($row); } } catch (PDOException $e) { print $e->getMessage(); } return $return; }
echo $section['titre'];