<?php
session_start();
include("forb.php");
include("check.php");
include("menu.php");
$q1 = mysql_query("SELECT * FROM ting_salg WHERE id = '$_GET[id]'") or die(mysql_error());
while($vis = mysql_fetch_array($q1)) {
$sal = mysql_query("SELECT * FROM koebte_t WHERE '$vis[ting_id]' AND ejer = '$_SESSION[Brugernavn]'") or die(mysql_error());
$antal = mysql_num_rows($sal);
if($antal == '0'){
print "Snyder!";
}else{
mysql_query("INSERT INTO koebte_t (navn, billede, ejer) VALUES ('$vis[navn]', '$vis[billede]', '$_SESSION[Brugernavn]')") or die(mysql_error());
mysql_query("DELETE FROM ting_salg WHERE id = '$_GET[id]'");
print "Du har nu trukket <b>$vis[navn]</b> tilbage.";
}
}
?>