<?
session_start();
?>
<html>
<head>
<body>
<meta name="Generator" content="Stone's WebWriter 4">
<link rel="stylesheet" type="text/css" href="style.css">
<?php include_once("check.php") ?>
<?php
include_once("connect.php");
include("menu.php");
?>
<h1>Ude af drift</h1>
<style='BORDER-RIGHT: #0000FF 3px dotted; BORDER-TOP: #0000FF 3px dotted; BORDER-LEFT: #0000FF 3px dotted; BORDER-BOTTOM: #0000FF 3px dotted' color='#0000FF'>
<body oncontextmenu="return false"ondragstart="return false"onselectstart="return false">

<?php
include_once("connect.php");
$tjek_session_bruger = mysql_query("SELECT * FROM brugere WHERE brugernavn = '$_SESSION[Brugernavn]'") or die(mysql_error());
$viss = mysql_fetch_array($tjek_session_bruger);

if($_GET[id] == "") {
$hent_div_tojer = mysql_query("SELECT * FROM butik_avis ORDER BY id DESC") or die(mysql_error());
while($vis = mysql_fetch_array($hent_div_tojer)) {
?><TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
  <TR>
    <TD 
    style="float:left"><img src="ting/<?php print"$vis[toj]";?>" border="0">
    <TD align=left width="100%">
<b>Beskrivelse:<br></b><?php
$wordwrap = wordwrap($vis[beskrivelse],200, " <br />&nbsp;\n");

echo $wordwrap;
?><hr>&nbsp;Pris: <b><?php print"$vis[pris2]";?></b> Mønter.<br>
  <a href="butik.php?id=<?php print"$vis[ID]";?>">&nbsp;Køb <b><?php print"$vis[navn]";?></b> nu!</a>
</TD></TR></TBODY></TABLE>
<hr>
<?
}
?>
<?php
}
if($_GET[id] != "") {
$hent_info_om_toj = mysql_query("SELECT * FROM butik_avis WHERE id = '$_GET[id]'") or die(mysql_error());
$vist = mysql_fetch_array($hent_info_om_toj);

$tjek_bruger_penge = mysql_query("SELECT * FROM brugere WHERE brugernavn = '$_SESSION[Brugernavn]'") or die(mysql_error());
$tjekker = mysql_fetch_array($tjek_bruger_penge);

if($tjekker[point] < $vist[pris]) {
print "<P><FONT color=#ff3333>Du har ikke råd til denne ting.</FONT> </P>";
}else{

$hent_info_om_toj = mysql_query("SELECT * FROM butik_avis WHERE id = '$_GET[id]'") or die(mysql_error());
$vist = mysql_fetch_array($hent_info_om_toj);

$pris = $vist[pris];
$monter_mig = $viss[point];
$toj = $vist[toj];
$brugernavn = $_SESSION[Brugernavn];

mysql_query("UPDATE brugere SET Point = Point-$pris WHERE brugernavn = '$brugernavn'") or die(mysql_error());
mysql_query("INSERT INTO ting (billede, tingnavn, brugernavn ) VALUES ('$vist[toj]', '$vist[navn]', '$_SESSION[Brugernavn]')")or die(mysql_error());
print "<P><FONT color=#00cc00>Du har nu købt en ny ting</FONT></P>";
?>

<?
}
}
?>
</html>
</head>
</body>