<?php
$extension = "php_gtk" . (strpos(PHP_OS, "WIN") >= 0 ? ".dll" : ".so");
dl($extension);

function killwin() {
	gtk::main_quit();
}

$window = &new GtkWindow();
$window->set_title("Testiranje!");
$window->set_usize(300, 200);
$window->set_position(GTK_WIN_POS_CENTER);
$window->set_policy(false, false, false);
$window->connect('destroy', 'killwin');

$box = &new GtkVBox();
$window->add($box);
///////////////////////////////////////////////////////////////////////
$label1 = &new GtkLabel("Host:");
$box->add($label1);
$label1 -> show();

$host = &new GtkEntry();
$host->set_text("localhost");
$box->add($host);
///////////////////////////////////////////////////////////////////////
$label2 = &new GtkLabel("User:");
$box->add($label2);
$label2 -> show();

$user = &new GtkEntry();
$user->set_text("root");
$box->add($user);
///////////////////////////////////////////////////////////////////////
$label3 = &new GtkLabel("Pass:");
$box->add($label3);
$label3 -> show();

$pass = &new GtkEntry();
$pass->set_text("");
$box->add($pass);
///////////////////////////////////////////////////////////////////////
$button = &new GtkButton("Vadi!");
$button->connect("clicked", "getData");
$box->pack_start($button);
///////////////////////////////////////////////////////////////////////


function getData() {
	global $host, $user, $pass;
	global $label1, $label2, $label3;
	global $button, $box;
	$label1->hide();
	$label2->hide();
	$label3->hide();
	$host->hide();
	$user->hide();
	$pass->hide();
	$button->hide();
	$s = @mysql_connect($host->get_text(), $user->get_text(), $pass->get_text());
	if (!$s) {
		$get_all = str_replace(":", "\n", mysql_error());
	}
	@mysql_select_db("peopole", $s);
	$query = "SELECT * FROM `programmers`";
	$query = @mysql_query($query);
	while ($row = @mysql_fetch_array($query)) {
		$get_all .= $row["pName"] . ", " . $row["pAge"] . "\n";
	}
	$p = &new GtkLabel("$get_all");
	$box->add($p);
	$p->show();
}


$window->show_all();
Gtk::main();
?>