<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Bewerk Reis</title>
<?php
include 'dbconnect.php';
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$query2= "UPDATE accomodations SET code='".$_POST['code']."' , land_id='".$_POST['land']."' , naam='".$_POST['naam']."' , plaats='".$_POST['plaats']."' , intro='".$_POST['intro']."' , vanafPrijs='".$_POST['prijs']."' , infoAlgemeen='".$_POST['beschrijving']."' , infoFaciliteiten='".$_POST['faciliteiten']."' , klasse='".$_POST['klasse']."' , details='".$_POST['aanbiedingen']."' , active='".$_POST['published']."', offer_price='".$_POST['offer']."' WHERE id='".$_GET['nid']."' ";
$result = mysql_query($query2) or die(mysql_error());
echo "Opgeslagen";
}
$query="SELECT * FROM accomodations WHERE id = '".(int)$_GET['nid']."' ";
$result = mysql_query($query) or die(mysql_error());
while ($record = mysql_fetch_assoc($result)) {
$land_id = $record['land_id'];
$code = $record['code'];
$alias = $record['alias'];
$naam = $record['naam'];
$plaats = $record['plaats'];
$intro = $record['intro'];
$vanafPrijs = $record['vanafPrijs'];
$infoAlgemeen = $record['infoAlgemeen'];
$infoFaciliteiten = $record['infoFaciliteiten'];
$klasse = $record['klasse'];
$plaats=$record['plaats'];
$offer=$record['details'];
$published=$record['published'];
}
$testquery=" SELECT accomodations.land_id, countries.id, countries.naam FROM accomodations INNER JOIN countries ON accomodations.land_id= countries.id WHERE countries.id=".$land_id." ORDER BY naam ";
$result2 = mysql_query($testquery) or die(mysql_error());
while ($record = mysql_fetch_array($result2)){
$naam2=$record['naam'];}
echo $naam2;
//Haal landen, reissoorten en accommodatie types op uit database, en geef weer in een dropdown
$sql = "SELECT DISTINCT naam FROM `countries` ORDER BY naam ";
$result = mysql_query($sql);
while($disp = mysql_fetch_array($result))
{
$country .= '<option value="'.$disp['id'].'"> '.$disp['naam'].' </option>';
}
$sql = "SELECT * FROM `reis_soorten` ";
$result = mysql_query($sql);
while($disp = mysql_fetch_array($result))
{
$soortreis .= '<option value="'.$disp['id'].'"> '.$disp['name'].' </option>';
}
$sql = "SELECT * FROM `accomodatie_types` ";
$result = mysql_query($sql);
while($disp = mysql_fetch_array($result))
{
$soortacco .= '<option value="'.$disp['id'].'"> '.$disp['name'].' </option>';
}
$checkbox = "SELECT active FROM `accomodations` WHERE id = '" .$_GET['nid']."' ";
$uitkomst = mysql_query($checkbox);
$check = mysql_fetch_array($uitkomst);
if (in_array("1", $check, TRUE)){
$published2 .= '<input type="checkbox" value="1" checked name="published" />';}
else {
$published2 .= '<input type="checkbox" value="1" name="published" />';
}
$checkbox2 = "SELECT offer_price FROM `accomodations` WHERE id = '" .$_GET['nid']."' ";
$uitkomst2 = mysql_query($checkbox2);
$check2 = mysql_fetch_assoc($uitkomst2);
if ($check2 >= 1) {
$published3 .= '<input type="checkbox" value="1" name="offer" />'; }
else {
$published3 .= '<input type="checkbox" value="1" checked name="offer" />';}
echo $check2;
?>
</head>
<body>
<form id="bewerken" name="bewerken" method="post" form action="">
<table width="560" border="0">
<tr>
<td>Naam</td>
<td><input type="text" name="naam" id="naam" value="<?php echo $naam;?>" /></td>
</tr>
<tr>
<td>Code</td>
<td><input type="text" name="code" id="code" value="<?php echo $code; ?>" /></td>
</tr>
<tr>
<td><label>Plaats </label></td>
<td><input type="text" name="plaats" id="plaats" value="<?php echo $plaats;?>" /></td>
</tr>
<tr>
<td><label>Vanaf Prijs</label></td>
<td><input type="text" name="prijs" id="prijs" value="<?php echo $vanafPrijs;?>" /></td>
</tr>
<tr>
<td><label>Land </label></td>
<td><select name="land" id="land">
<option value="<?php echo $land_id;?>" selected="selected"><?php echo $naam2;?> </option>
<option value="" /><?php echo $country?></option>
</select></td>
</tr>
<tr>
<td><label>Soort Reis</label></td>
<td><select name="soortreis" id="soortreis">
<option value=""> <?php echo $soortreis;?> </option>
</select></td>
</tr>
<tr>
<td><label>Soort Accommodatie</label></td>
<td><select name="soortacco" id="soortacco">
<option value=""> <?php echo $soortacco;?> </option>
</select></td>
</tr>
<tr>
<td>Klasse</td>
<td><select name="klasse" id="klasse">
<option value="<?php echo $klasse;?>"> <?php echo $klasse;?> </option>
</select></td>
</tr>
<tr>
<td><label>Korte tekst</label></td>
<td><textarea name="intro" id="intro" cols="45" rows="5"><?php echo $intro;?></textarea></td>
</tr>
<tr>
<td><label>Volledige Beschrijving</label></td>
<td><textarea name="beschrijving" id="beschrijving" cols="45" rows="5"><?php echo $infoAlgemeen;?></textarea></td>
</tr>
<tr>
<td><label>Faciliteiten</label></td>
<td><textarea name="faciliteiten" id="faciliteiten" cols="45" rows="5"><?php echo $infoFaciliteiten;?></textarea></td>
</tr>
<tr>
<td><label>Aanbiedingen</label></td>
<td><textarea name="aanbiedingen" id="aanbiedingen" cols="45" rows="5"><?php echo $offer;?></textarea></td>
</tr>
<tr>
<td><?php echo $published3; ?></td>
<td><label>Als Aanbieding tonen?</label></td>
</tr>
<tr>
<td><?php echo $published2; ?></td>
<td><label>Laten zien op de site?</label></td>
</tr>
</table>
<p>
<label>
<input type="submit" name="opslaan" id="opslaan" value="opslaan" />
</label>
</p>
</body></form>
</html>
<?php
?>