Location: PHPKode > scripts > phpSortable > phpsortable/phpSortable/examples/example_02.php
<?php

/**
 * Another example on using this class <br>
 * ----------------------------------- <br><br>
 * 
 * last review: 04.02.07  <br>
 * 
 * @author Wagner O. Wutzke <hide@address.com>
 * 
 * @version 2.0 
 * 
 * @link http://www.phpclasses.org/browse/package/3704.html
 *
 * @package phpSortable 
 * 
 * */

	require_once "../class.phpSortable.php";
	require_once "../activeDBLib/activeDBLib.php";
	
	$yourHost 	= "localhost";
	$yourDB 	= "usr_web314_1";
	$yourUser 	= "root";
	$yourPass	= "";
	$dbtype 	= "mysql"; 	# see activeDBLib documentation 
							# for others DB types (manual.html)
	
	$sql = 
	"SELECT DISTINCT " .
		"a.name, a.vorname, a.mail, a.zimmer, a.geb_datum, a.user, a.pass, a.user_id, " .
		"b.name AS tutor " .
		"FROM user a, tutorium b, user_tutorium c " .
		"WHERE " .
			"a.user_id = c.user_id AND " .
			"c.tutorium_id = b.id";
	
	$db = new activeDBLib($dbtype);
	$db->debug(); # catch all errors and exit the application if any
	$db->connect($yourHost, $yourUser, $yourPass, $yourDB);
	$db->execute($sql);
	
	$col_9 = new phpSortColumn("user_id", "ID");
	$col_1 = new phpSortColumn("vorname", "Vorname");
	$col_2 = new phpSortColumn("name", "Name");
	$col_3 = new phpSortColumn("mail", "e-Mail");
	$col_4 = new phpSortColumn("geb_datum", "Geboren am");
	$col_5 = new phpSortColumn("zimmer", "Zimmer");
	$col_6 = new phpSortColumn("foto_id", "Foto ID");
	$col_7 = new phpSortColumn("user", "Username");
	$col_8 = new phpSortColumn("pass", "Password");
	$col_0 = new phpSortColumn("tutor", "Tutorium");
	
	$columns = array(0=>$col_0, 1=>$col_1, 2=>$col_2, 3=>$col_3, 4=>$col_4, 
						5=>$col_5, 6=>$col_6, 7=>$col_7, 8=>$col_8, 9=>$col_9);
	
	# create a new phpSortable object with the abstracted db object
	# and the array of column object
	$sortable = new phpSortable($db, $columns);
	
	$sortable->setTableFormat ("2", "2", "0"); // cellpadding, cellspacing, border
	
	$sortable->editLink = "editlink.php";
	$sortable->deleteLink = "deletelink.php";
	$sortable->addLink = "addlink.php";
	$sortable->addText = "add a new entry";
	$sortable->urlKeyName = "id";
	$sortable->tableKeyName = "besucher_id";
    $sortable->tableTitle = "Tutors List";
	
	$sortable->editTarget = "_blank";
	$sortable->editWindowFormat = "'width=300,height=400'";
	
	$sortable->editPromptMsg = "Do you really wish to edit this entry?";
	$sortable->deletePromptMsg = "Do you really wish to delete this entry?";
	
	#define the deafult row number to be displayed
	$sortable->defaultRowsNum = "10";
	
	#define the path for the css file
	$sortable->cssFilePath = "../phpSortable.css";
	
	#define the path for of the images directory
	$sortable->imgFilePath = "../img/";
	
	$sortable->printTable();
   
?>
Return current item: phpSortable