<?php
/* $Id: hello.php,v 1.6 2002/11/25 18:22:05 fmk Exp $ */
//
//
if (!class_exists('gtk')) {
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN')
dl('php_gtk.dll');
else
dl('php_gtk.so');
}
//
function delete_event(){
return false;
}
//
function destroy(){
Gtk::main_quit();
}
//
function buttons(){
global $window;
gdk::beep();
$window->destroy();
}
//
$window = &new GtkWindow();
$window->connect('destroy', 'destroy');
$window->connect('delete-event', 'delete_event');
$window->set_border_width(10);
$window->show();
//
$Hbox_start = &new GtkHBox(false, 5);
$window->add($Hbox_start);
//
$vbox = &new GtkVBox(false, 5);
$Hbox_start->add($vbox);
//
//
//
$frame = &new GtkFrame("Close section");
$frame->set_label("Click to exit");
$frame->set_label_align(0.0, 0.5);
$frame->set_shadow_type(GTK_SHADOW_ETCHED_IN);
$frame->show();
$vbox->pack_start($frame, true, true, 5);
//
//
$hbox1 = &new GtkHBox(false, 5);
//
//
$label = &new GtkLabel();
$label->set_text("To close this window all you have \n
to do is click on the button below. \n
But be warned!! I can not be held \n
responsible for what else it might do.");
$label->set_justify(GTK_JUSTIFY_LEFT);
$frame->add($label);
$label->show();
//
//
$hbox2 = &new GtkHBox(false, 5);
$vbox->add($hbox2);
//
//
$button = &new GtkButton('Close');
$button->connect('clicked', 'buttons');
$button->show();
$hbox2->pack_start($button, true, true, 5);
//
//
//
$tt = &new GtkTooltips();
$tt->set_delay(200);
$tt->set_tip($button, 'Closes out this Window', '');
$tt->enable();
//
$vbox_section2 = &new GtkVBox(false, 5);
$Hbox_start->add($vbox_section2);
//
$frame2 = &new GtkFrame("Close section");
$frame2->set_label("Database connection");
$frame2->set_label_align(0.0, 0.5);
$frame2->set_shadow_type(GTK_SHADOW_ETCHED_IN);
$frame2->show();
$vbox_section2->pack_start($frame2, true, true, 5);
//
//
$db_conn = mysql_connect ("address to server", Login, password);
mysql_select_db(Login, $db_conn);
$name = mysql_query("SELECT * FROM Userinfo Where id = '1'");
while($name2 = mysql_fetch_array($name)) {
$handle = "".$name2['First']." ".$name2['Last']."";
}
//
if ($db_conn){
$label2 = &new GtkLabel();
$label2->set_text("Hello $handle, \n
If you are reading this \n
then you are connected \n
to the database.");
$label2->set_justify(GTK_JUSTIFY_LEFT);
$frame2->add($label2);
$label2->show();
}else{
$label2 = &new GtkLabel();
$label2->set_text("mySQL Error: ".mysql_error());
$label2->set_justify(GTK_JUSTIFY_LEFT);
$frame2->add($label2);
$label2->show();
}
//
/*realize the underlying GdkWindow, flag the GtkWindow's visibility and map
it onto the screen, all in one simple line*/
//
$window->show_all();
//
/*without the main loop, there is no PHP-GTK script*/
//
Gtk::main();
?>