Location: PHPKode > projects > The Community Wish List Server > wlserver/admin/wbw.php
<?php

print("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
print("<!DOCTYPE html\n");
print("PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n");
print("\t\" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\" >\n");
print("\t<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n");
print("\t\t<head>\n");
print("\t\t\t<title>Purchase Query</title>\n");
print("<script language=\"JavaScript1.2\" type=\"text/javascript\" src=\"../wishlist.js\"></script>\n");
print("<link rel=\"STYLESHEET\" type=\"text/css\" href=\"../wishlist.css\" />");
print("\t\t</head>\n");
print("\t<body bgcolor=\"#ffffff\">\n");

if ($action !="1") {

	include("../../php/dbconnect.php");
	$userList="
		select
			personKey,
			fName, 
			Lname
		from
			person";
	$userListGot=mysql_query($userList);
	include("../../php/dbdisconnect.php");
	
	if (!$userListGot) die ("Could not get the user list.<br />".mysql_error());
	
	$numUsers = mysql_num_rows($userListGot);
	
	print ("Select the user to inquire about.<br />");
	print ("<form method=\"post\" action=\"wbw.php\">\n");
	print ("<select name=\"user\">\n");
	for ($userLoop = 0; $userLoop < $numUsers; $userLoop++) {
		$key = mysql_result($userListGot,$userLoop,"personKey");
		$name = mysql_result($userListGot,$userLoop,"fName")." ".mysql_result($userListGot,$userLoop,"lName");
		print ("<option value=\"$key\">$name</option>\n");
	}
	print ("</select>\n");
	print ("<input type=\"hidden\" name=\"action\" value=\"1\">\n");
	print ("<input type=\"submit\">\n");
	print ("</form>\n");
	print ("</body>\n</html>\n");

} else {
	
	include ("../../php/dbconnect.php");
	$getUser="
		select
			fName,
			lName
		from
			person";
	$users=mysql_query($getUser);
	$name = mysql_result($users,0,"fName")." ".mysql_result($users,0,"lName");
	
	print ("<p>These are the gifts claimed from $name's wish list.</p>\n");
	
	$giftsForPersonQuery="
		select
			g.giftName as gift,
			p.fName as fName,
			p.lName as lName,
			gcb.dateClaimed as date
		from
			person p,
			giftList g,
			giftClaimedBy gcb,
			personWishesForGift pwfg
		where
			g.giftKey = gcb.giftKey and
			p.personKey = gcb.personKey and
			gcb.giftKey = pwfg.giftKey and
			pwfg.personKey = $user";
	$giftsClaimed=mysql_query($giftsForPersonQuery);
	if (!$giftsClaimed) die ("Could not select gift information: <br /><b>$giftsForPersonQuery</b><br />".mysql_error());
	$numClaims=mysql_num_rows($giftsClaimed);
	print ("<table border=\"1\">\n");
	print ("<tr><th>Gift</th><th>Purchaser</th><th>Date Claimed</th></tr>\n");
	for ($claimLoop = 0; $claimLoop < $numClaims; $claimLoop++) {
		$gift=mysql_result($giftsClaimed,$claimLoop, "gift");
		$name = mysql_result($giftsClaimed,$claimLoop,"fName")." ".mysql_result($giftsClaimed,$claimLoop,"lName");
		$date=mysql_result($giftsClaimed,$claimLoop, "date");
		print("<tr><td>$gift</td><td>$name</td><td>$date</td></tr>\n");
	}
	print("</body>\n</html>\n");
}

?>
Return current item: The Community Wish List Server