<?php

include('functions.php');
include('db.inc.php');

if($round) {

	while (list($key, $val) = each($_POST)) {
		if ($key<>"id" && $key<>"Submit" && $key<>"round"){
			$set.=$key ."='". strtr($val,"'\"","´´") . "', ";
		}
	}

	$set=substr($set,0, strlen($set)-2);

	$stmt="UPDATE kk_ajanlat SET $set WHERE id='$id'";
	$mydb = new db();
	$result=$mydb->query($stmt);
	//header("Location:a_ajanlat.php");
	echo "<script>alert('Sikeres módosítás!');document.location.replace('a_ajanlat_edit.php?id=$id');</script>";


} else {

$title="szerkesztes";

	include('header.inc.php');

	$mydb = new db();

	$stmt="SELECT * FROM kk_ajanlat WHERE id='$id'";

	$result=$mydb->query($stmt);

	printf("<H5>Szerkesztés</H5>");


	while($row = mysql_fetch_object($result)){

		for($field_index=0; $field_index<mysql_num_fields($result); $field_index++){
			$field_name=mysql_field_name($result, $field_index);
			$data[$field_name]=stripslashes($row->$field_name);
		}

		generate_html_form('ajanlat', $data, $PHP_SELF);
	}

	include('footer.inc.php');

}

?>
