Cyperfriend
Der ohne Avatar
- Registriert
- 14 Juli 2013
- Beiträge
- 1.123
Kann mir bitte jemand erklären, wie ich daraus eine Funktion machen kann und wie ich sie dann aufrufen kann?
[src=php]# Datenfankverbindung herstellen
$db_connect = db_connect();
// Auslesen der Standorte
if(!isset($_GET['locationid'])){
$statement = $db_connect->query("select * from db_locations");
$locations = $statement->fetchALL(PDO::FETCH_ASSOC);
} else {
$statement = $db_connect->prepare("select * from db_locations where location_id = :locationid");
$statement->execute(['locationid' => $_GET['locationid']]);
$location = $statement->fetch(PDO::FETCH_ASSOC);
}[/src]
[src=php]# Datenfankverbindung herstellen
$db_connect = db_connect();
// Auslesen der Standorte
if(!isset($_GET['locationid'])){
$statement = $db_connect->query("select * from db_locations");
$locations = $statement->fetchALL(PDO::FETCH_ASSOC);
} else {
$statement = $db_connect->prepare("select * from db_locations where location_id = :locationid");
$statement->execute(['locationid' => $_GET['locationid']]);
$location = $statement->fetch(PDO::FETCH_ASSOC);
}[/src]