<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
 <HEAD>
  <TITLE>
	Welcome to Iyad Abu-Jeib's Guestbook
  </TITLE>
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
 </HEAD>
 <BODY>
	<H1 ALIGN="center">Welcome to My Guestbook</H1>

<?

@$d = mysql_connect('localhost','abu-jeib','iyad911') or  die("<p>We can't process your request at this time.</p>");

@mysql_select_db('guestbook') OR die ("<p>We can't process your request at this time.</p>");


@$q = "select * from gbook"; 
@$r = mysql_query($q) OR die ("<p>We can't process your request at this time.</p>");

while (@$row = mysql_fetch_row($r))
{
	for ($i = 0; $i < mysql_num_fields($r) - 1;$i++)
	{
		$field = trim(mysql_field_name($r,$i));
		$data = trim ($row[$i]); 
	     	if (!empty($data) && $data != "NULL")
		{
			if ($field == "homepage")
				echo "<b>Homepage: </b> <a href=\"$data\">$data</a><br>\n";
			else if ($field == "email")
				echo "<b>Email: </b> <a href=\"mailto:$data\">$data</a><br>\n";
			else if ($field == "message")
			{
				$data = str_replace("\n","<br>",$data);
				$data = str_replace(" ","&nbsp;",$data);
				$data = str_replace("\t","&nbsp;&nbsp;&nbsp;&nbsp;",$data);
				echo "<b>Message:</b> $data";
			}
			else
				echo "<b>", ucfirst($field), ": </b> $data<br>\n";
				
		}
	}
	echo "<hr color='black' size='3'>\n";
}
echo "<center><A href=\"sign_guestbook.php\">Sign My Guestbook</A></center>";

echo "</ol></body></html>\n";
@mysql_close($d) OR die(); 
?>
