<html>
<head>

<?php
include('func.php');

// in case we don't have register_globals on. all we need to start
// with is the name of the person with comments
$name="";
// for cli testing
$name="BluBlaDe";

if (isset($_GET['name'])) {
	$name=$_GET['name'];
}
else {
	exit;
}

include("css.php");
echo"<title>SMS- Comments for '$name'</title>\n";
echo "</head>\n\n";

include("body.php");

/* declare some relevant variables */

include("db.inc.php");
$table = "alex_comments";

$today = date("Y-m-d");

/* make connection to database */
$myconn = MYSQLI_CONNECT($hostname,$username,$password,$dbName) OR DIE("Unable to connect to  database");
//@mysql_select_db("$dbName") or die("Unable to select database");


/* just a simple check to see if it went in */
$query = "SELECT * FROM $table WHERE(name = '$name') AND active = '1' ORDER BY date_added DESC;";
$result = MYSQLI_QUERY($myconn, $query);
$number = MYSQLI_NUM_ROWS($result);

echo "<B>$number reviews by $name..</B><BR>\n\n";
//echo "<font face=\"Arial Narrow, Arial\" size=2>\n";

$i = 0;
IF ($number == 0) :
	PRINT "<CENTER><P>No comments for \"$name\".</CENTER>\n\n";
ELSEIF ($number > 0) :
	WHILE ($i < $number):

		$name = mysqli_result($result,$i,"name");
		$email = mysqli_result($result,$i,"email");
		$comment = mysqli_result($result,$i,"comment");
		$rating = mysqli_result($result,$i,"rating");
		$game_title = mysqli_result($result,$i,"game_title");
		$game_id = mysqli_result($result,$i,"game_id");
		$date_added = mysqli_result($result,$i,"date_added");

	$namequery = "SELECT game_title FROM alex_games WHERE(ID = '$game_id');";
	$nameresult = MYSQLI_QUERY($myconn, $namequery);

	$gamename = mysqli_result($nameresult,0,"game_title");

			PRINT "<blockquote>\n";
			PRINT "<b><a href=\"show_game.php?ID=$game_id\">$gamename</a></b><br><br>\n";
			//PRINT "<font size=2>$date_added</font><BR>\n";
			PRINT "$date_added<BR>\n";
			PRINT "<B>From:</B> <I>\n";
			IF ($email == "") {
				PRINT "$name</I><BR>\n";
			}
			ELSE {
				PRINT "<a href=mailto:$email>$name</a></I><BR>\n";
			}
			PRINT "<B>Comments:\n";
			PRINT "</B><I> \n";
			PRINT "$comment\n";
			PRINT "</I><BR>\n";
			PRINT "<BR><B>Rating:</B> \n";
/* This is the loop to print the Kidd's */
	IF ($rating > 0) {
		$rate_count = 0;
		WHILE ($rate_count < $rating):
				//PRINT "<img src=../images/alex_kidd_icon.gif height=24 width=16>\n";
				echo "<img src=../images/alexkidd.png height=24 width=16>\n";
			$rate_count++;
		ENDWHILE;
	}
	ELSE {
		PRINT "n/a\n";
	}
/* end of Kidd printing loop */

			PRINT "<BR><BR><HR width=80% noshade color=#FF0000><BR>\n";
			PRINT "</blockquote>\n";
		$i++;
	ENDWHILE;
//		PRINT "<BR>";
ENDIF;

//PRINT "</font>\n";



/* Close the database connection */
MYSQLI_CLOSE($myconn);


include("analytics.php");

?>

</body>

