Location: PHPKode > projects > PHP MySQL Address Book > addressbook/addresscard.php
<?php
require("sesionchk.php");
?>
<html>
<head>
<title>
<?php
require("title.php");
?>
</title>
<!--<link rel="stylesheet" type="text/css" href="styles/wide_screen.css">-->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>

<body>
<?php

require("links.php");
include 'library/config.php';
include 'library/opendb.php';
/*
// how many rows to show per page
$rowsPerPage = 20;

// by default we show first page
$pageNum = 1;

// if $_GET['page'] defined, use it as page number
if(isset($_GET['page']))
{
	$pageNum = $_GET['page'];
}

// counting the offset
$offset = ($pageNum - 1) * $rowsPerPage;
*/
//$query  = "SELECT FirstName,EmailAddress,ID FROM contacts LIMIT $offset, $rowsPerPage";
if ($_GET[value]=="all")
{
//$query  = "SELECT FirstName,EmailAddress,ID FROM contacts ORDER BY FirstName  ASC";
$query  = "SELECT `FirstName`,`BusinessStreet`,`BusinessPhone`,`BusinessPhone2`,`BusinessFax`,`MobilePhone`,`HomePhone`,`HomePhone2`,`EmailAddress`,`Email2Address`,`Email3Address`,ID,user_id FROM contacts ORDER BY FirstName  ASC";
}
else
{
//$query  = "SELECT FirstName,EmailAddress,ID FROM contacts where FirstName like '".$_GET[value]."%' ORDER BY FirstName  ASC";
$query  = "SELECT `FirstName`,`BusinessStreet`,`BusinessPhone`,`BusinessPhone2`,`BusinessFax`,`MobilePhone`,`HomePhone`,`HomePhone2`,`EmailAddress`,`Email2Address`,`Email3Address`,ID,user_id FROM contacts where FirstName like '".$_GET[value]."%' ORDER BY FirstName  ASC";
}
mysql_query("SET NAMES 'utf8'");
mysql_query('SET CHARACTER SET utf8'); 
$result = mysql_query($query) or die('Error, query failed');
?>


<table width="100%" border="0" cellspacing="1" cellpadding="1">
  <tr>
    <td style=" vertical-align: top;">
	</td>
    <td>
	<?php
	
foreach (range('A', 'Z') as $letter) {
	echo " <a href=\"".$_SERVER['PHP_SELF']."?type=sort&value=".$letter."\" class=\"text\">".$letter."</A>  ";
} 
echo " <a href=\"".$_SERVER['PHP_SELF']."?type=sort&value=all\" class=\"text\">All</A> ";
echo "<table width=520 border='1' cellpadding='1' cellspacing='1' bordercolor='#000000'> <COLGROUP span='10' width='0*'>";
echo "<tr><td><h2>Contacts</h2></td><td colspan='2'>";

echo "</td></tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
	echo "<td>";
	if ($_SESSION['usr_level'] <>3 or $_SESSION['usr_id']==$row['user_id'])
	{
	echo "<a href=\"wabraaddressbook.php?ID=".$row['ID']."\">Edit</a>";
	}
	else
	{
	echo "<a href=\"wabraaddressbook.php?ID=".$row['ID']."\">View</a>";
	}
	echo "</td>";
	echo "<td>";
	if (trim($row['FirstName'])!=="")
	{
	echo "<b>".$row['FirstName']."</b><br>";
	}
	//echo "</td>";
	//echo "<td>";
	if (trim($row['BusinessStreet'])!=="")
	{
	echo $row['BusinessStreet']."<br>";
	}
	
	if (trim($row['BusinessPhone'])!=="")
	{
	echo "Business:&nbsp;&nbsp;".$row['BusinessPhone']."<br>";
	}
		if (trim($row['BusinessPhone2'])!=="")
	{
	echo "Business 2: 2&nbsp;&nbsp;".$row['BusinessPhone2']."<br>";
	}
	if (trim($row['BusinessFax'])!=="")
	{
	echo "Business Fax:&nbsp;&nbsp;".$row['BusinessFax']."<br>";
	}
	if (trim($row['MobilePhone'])!=="")
	{
	echo "Mobile:&nbsp;&nbsp;".$row['MobilePhone']."<br>";
	}
	
	if (trim($row['HomePhone'])!=="")
	{
	echo "Home:&nbsp;&nbsp;".$row['HomePhone']."<br>";
	}

	if (trim($row['HomePhone2'])!=="")
	{
	echo "Home 2:&nbsp;&nbsp;".$row['HomePhone2']."<br>";
	}

	if (trim($row['EmailAddress'])!=="")
	{
	echo "E-mail:&nbsp;&nbsp;<a href='mailto:".trim($row['EmailAddress'])."'>" .trim($row['EmailAddress'])."</a><br>";
	}
	if (trim($row['Email2Address'])!=="")
	{
		echo "E-mail 2:&nbsp;&nbsp;<a href='mailto:".trim($row['Email2Address'])."'>" .trim($row['Email2Address'])."</a><br>";
	}

	if (trim($row['Email3Address'])!=="")
	{
	echo "E-mail 3:&nbsp;&nbsp;<a href='mailto:".trim($row['Email3Address'])."'>" .trim($row['Email3Address'])."</a><br>";
	}

	echo "<td>";
	if ($_SESSION['usr_level'] <>3 or $_SESSION['usr_id']==$row['user_id'])
	{	
	echo "<a href=\"wabraaddressbook.php?ID=".$row['ID']."&salph=".$_GET[value]."&mod=del\">Delete</a>";
	}
	else
	{
	echo "&nbsp;";
	}
	//echo "<a href=\"library/delrec.php?ID=".$row['ID']."&salph=".$_GET[value]."\">Delete</a>";
	echo "</td>";
	
	echo "</tr>";
/*


	echo $row['FirstName'] ." <a href=\"wabraaddressbook.php?ID=".$row['ID']."\">Edit</a> &nbsp; <a href=\"library/delrec.php?ID=".$row['ID']."&salph=".$_GET[value]."\">Delete</a> <br>";
	*/
}
echo '</table>';
include 'library/closedb.php';
?>
	</td>
  </tr>
</table>
</body>
</html>
Return current item: PHP MySQL Address Book