<?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 ."='". addslashes($val) . "', ";
		}
	}

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

	$stmt="UPDATE kk_lista SET $set WHERE id='$id'";

	$mydb = new db();
	$result=$mydb->query($stmt);
	header("Location:a_lista.php");

} else {

$title="szerkesztes";

	include('header.inc.php');

	$mydb = new db();

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

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

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


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

        $s_ids = $row->ids;

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

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


	printf("<H3>A lista tagjai</H3>");



    $a_ids = unserialize(base64_decode($s_ids));

    if (sizeof($a_ids) > 0) {
        $s_query = 'SELECT * FROM kk_tag WHERE ';
        foreach ($a_ids as $i_current) {
            $s_query .= "id = '". $i_current . "' OR ";
            }

        $s_query = substr($s_query, 0, strlen($s_query)-4);
        $result=$mydb->query($s_query);

        printf("<TABLE border='1' style='border-collapse: collapse' bordercolor='#CCCCCC' CELLPADDING='5' STYLE='background: #FFFFFF;'>");
        while($row = mysql_fetch_object($result)){
            printf("<tr><td>%s</td><td>%s</td><td><A HREF='a_tag_edit.php?id=%s' TARGET='_blank'>megnyit</A> | <A HREF='a_lista_remove.php?list_id=%s&id=%s'>töröl</A></td></tr>", $row->id, $row->nev, $row->id, $id, $row->id);
            }
        printf("</table>");
    } else {
        printf("Üres lista");
        }
	include('footer.inc.php');

}

?>
