Location: PHPKode > projects > PHP MySQL Address Book > addressbook/wabraaddressbook.php
<?php
require("sesionchk.php");
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php
require("title.php");
?></title>

</head>

<body>
<?php
require("links.php");
include 'library/config.php';
include 'library/opendb.php';
if ($_GET['ID']!==-1)
{
if ($_GET['mod']=="del")
{
echo "<strong>Do you really want to Delete this Record? <a href=\"library/delrec.php?ID=".$_GET['ID']."&salph=".$_GET[salph]."\">Yes</a> <a href='dtaildaddresscard.php?type=sort&value=".$_GET['salph']."'> No </a></strong><hr>";
//<button onclick='window.close()' value='No'/>";

}
else
{

}
//$query = "SELECT FirstName,EmailAddress,ID,Notes,imagename FROM contacts where ID=" .$_GET['ID'];
$query = "SELECT `Title`,`FirstName` , `JobTitle` , `Company` , `BusinessPhone` , `HomePhone` , `BusinessFax` , `MobilePhone` , `BusinessStreet` , `HomeStreet` , `OtherStreet` , `EmailAddress` , `WebPage` , `Notes` , `ID`,`Categories`,`user_id`,`user_id2`,`updatedon` FROM contacts where ID=" .$_GET['ID'];
mysql_query("SET NAMES 'utf8'");
mysql_query('SET CHARACTER SET utf8'); 
/*$db_charset = mysql_query( "SHOW VARIABLES LIKE 'character_set_database'" );
$charset_row = mysql_fetch_assoc( $db_charset );
mysql_query( "SET NAMES '" . $charset_row['Value'] . "'" );
unset( $db_charset, $charset_row );

*/
$result = mysql_query($query);
$row = mysql_fetch_array($result, MYSQL_ASSOC);
if ($row['user_id'] >0)
{

$qry="select user from  `cal_accounts` where id=".$row['user_id'];
mysql_query("SET NAMES 'utf8'");
mysql_query('SET CHARACTER SET utf8'); 
$r=mysql_query($qry);
$ro = mysql_fetch_array($r, MYSQL_ASSOC);
$addedby=$ro['user_id'];

$qry="select user from  `cal_accounts` where id=".$row['user_id2'];
mysql_query("SET NAMES 'utf8'");
mysql_query('SET CHARACTER SET utf8'); 
$r=mysql_query($qry);
$ro = mysql_fetch_array($r, MYSQL_ASSOC);
$lastupdatedby=$ro['user_id'];

}
}
/*
    echo "Name :{".$row['FirstName']."} <br>" .
         "Subject : {".$row['EmailAddress']."} <br>" ;

 $name=$row['FirstName'];
 echo $name;*/
//include 'library/closedb.php';
if (trim($addedby)!="")
{
?>
<table >
<tr>
<?php
echo "<td width='10%'>Added By: ".$addedby;

if (trim($row['updatedon'])!="")
		{
		echo "</td><td width='10%'>Last Updated By: ".$lastupdatedby." on ".$row['updatedon'] ."</td>";
//		echo "<td width='5%'>on </td><td width='20%'>".$row['updatedon'] ."</td>";
		}
		else
		{
		echo "</td><td width='10%'>Last Updated By: ".$lastupdatedby."</td>";
		}
		

?>
</tr>
</table>
<?php

echo "<hr>";
}
?> 
<form id="msgform" name="msgform" method="post">
  <table width="98%" border="0">
  <tr>
    <td width="9%">Full Name </td>
    <td width="27%"><table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
	   <td width="44"><input type="text" name="title" size="4" value= "<?php echo $row['Title'];?>" /></td>
        <td width="204"><input type="text" name="fullname" id="fullname" value= "<?php echo $row['FirstName'];?>" width="200"/></td>
      </tr>
    </table></td>

    <td width="13%">E-mail</td>
    <td width="38%"><input type="text" name="txtemail" value= "<?php echo $row['EmailAddress'];?>" width="250"/>
	<?php 
	if (trim($row['EmailAddress'])!=="")
	{

echo "<br><a href='mailto:".trim($row['EmailAddress'])."'>" .trim($row['EmailAddress'])."</a><br>";
	
	 }
	?>	</td>
	<td>
	<?php
	
	if ($_SESSION['usr_level'] <>3 or $_SESSION['usr_id']==$row['user_id'] or $_GET['ID']==-1)
	{?>
	<input type="submit" name="submit2" value="    Save    " onclick="form.action='saveaddr.php?a=1';" onsubmit"return checkForm();" />
	<?php 
	}
	else
	{
	echo "&nbsp;";
	}
	?>
	</td>
  </tr>
  <tr>
    <td>Job Title </td>
    <td><input name="jobtitle" type="text" value="<?php echo $row['JobTitle'];?>" width="250"/></td>
    <td>Web page Address </td>
	<?php
	if (trim($row['WebPage'])=="")
	{
	$wbpage="http://www.";
	}
	else
	{
	$wbpage=trim($row['WebPage']);
	}
	?>
    <td><input name="webpageaddress" type="text" value="<?php echo $wbpage;?>" width="250"/>
	<?php 
	if (trim($row['WebPage'])!=="")
	{

echo "<br><a href='".trim($row['WebPage'])."'>" .trim($row['WebPage'])."</a><br>";
	
	 }
	?></td>
	
	<td width="13%">
	<?php
	
	if ($_SESSION['usr_level'] <>3 or $_SESSION['usr_id']==$row['user_id'] or $_GET['ID']==-1)
	{?>
	<input type="submit" name="submit2" value="Add Details" onclick="form.action='saveaddr.php?a=2';" />
	<?php 
	}
	else
	{
	echo "&nbsp;";
	}
	?>
	</td>
  </tr>
  <tr>
    <td>Company</td>
    <td><input name="company" type="text" value="<?php echo $row['Company'];?>" width="250"/></td>
   <td colspan="2" rowspan="11"><textarea name="notes" rows="30" style="width: 450px"><?php echo $row['Notes'];?></textarea></td>
	<td>
	<?php
	
	if ($_SESSION['usr_level'] <>3 or $_SESSION['usr_id']==$row['user_id'] or $_GET['ID']==-1)
	{?>
	<input type="submit" name="submit" value="Add Image" onclick="form.action='saveaddr.php?a=0&adb=s';" />
	<?php 
	}
	else
	{
	echo "&nbsp;";
	}
	?></td>
  </tr>
  
  <tr>
    <td><strong>Phone Numbers</strong> </td>
    <td><input type="hidden" name="addrid" value= "<?php echo $row['ID'];?>" /></td>
    <td rowspan="18" style="vertical-align:top;">
	<?php
	if ($_GET['ID']!==-1)
{
//$query = "SELECT FirstName,EmailAddress,ID,Notes,imagename FROM contacts where ID=" .$_GET['ID'];
$query = "SELECT `imagename` , `imagedesc` FROM `tblimages` WHERE id =" .$_GET['ID'];
mysql_query("SET NAMES 'utf8'");
mysql_query('SET CHARACTER SET utf8'); 

$imgresult = mysql_query($query);
//$row = mysql_fetch_array($imgresult, MYSQL_ASSOC);
		if (mysql_num_rows($imgresult)>0)
		{
		echo "<table>";//<tr><td></td><td></td></tr>";
	echo "<tr>Click To Zoom</tr>";
		
				while($imgrow = mysql_fetch_array($imgresult))
				{
					if (trim($imgrow)!=="")
						{
						echo "<tr>";
						
						
						$p="uploads/".$imgrow['imagename'];
$mw='100';
$mh='70';
 if(list($w,$h) = @getimagesize($p)) {
    foreach(array('w','h') as $v) { $m = "m{$v}";
        if(${$v} > ${$m} && ${$m}) { $o = ($v == 'w') ? 'h' : 'w';
        $r = ${$m} / ${$v}; ${$v} = ${$m}; ${$o} = ceil(${$o} * $r); } }
//echo "<center><img src='{$p}' alt='image' width='{$w}' height='{$h}'><br></center>";
	echo "<a href='showimage.php?a=".$imgrow['imagename']."&ID=".$_GET['ID']."&fn=s' target='_blank'><img src='uploads/".$imgrow['imagename']."' alt='Zoom In' width='{$w}' height='{$h}'></a>";
	}
else
{
	echo "<a href='showimage.php?a=".$imgrow['imagename']."&ID=".$_GET['ID']."&fn=s' target='_blank'><img src='uploads/".$imgrow['imagename']."' alt='Zoom In' height='70' width='100'></a>";

}				//		echo "<a href='uploads/".$imgrow['imagename']."' target='_blank'><img src='uploads/".$imgrow['imagename']."' alt='Zoom In' height='70' width='100'></a>";
						echo "<br>";
//						echo "<tr>";
$imgrowtmp =str_replace('.','',$imgrow['imagename']);
echo "<textarea name=\"". $imgrowtmp ."\" rows='4' style='width: 100px'>".$imgrow['imagedesc']."</textarea>";
//						echo $imgrow['imagedesc'];
						echo "<br>";

//						echo "<tr>";
						echo "<a href='showimage.php?a=".$imgrow['imagename']."&ID=".$_GET['ID']."&fn=s&mod=del'>Delete</a>";
//						echo "<a href='library/delimg.php?ID=".$row['ID']."&nam=".$imgrow['imagename']."&FN=s'>Delete</a>";
						echo "<br>";
						
						/*echo "<td>".$i."</td>";
						$gh=$i+1;
						echo "<td>".$gh."</td>";
						*/
						}
				
				}
				
				
				
			echo "</table>";	
				
		}
}
	
	/*
	
	if (trim($row['imagename'])!=="")
	{
	$indimg = explode(",", trim($row['imagename']));
	echo "<table>";//<tr><td></td><td></td></tr>";
	echo "<tr>Click To Zoom</tr>";
	for($i = 0; $i< count($indimg); $i++){
	if (trim($indimg[$i])!=="")
	{
	echo "<tr>";
	echo "<a href='uploads/".$indimg[$i]."' target='_blank'><img src='uploads/".$indimg[$i]."' alt='Zoom In' height='70' width='100'></a>";
	echo "</tr>";
	echo "<tr>";
	echo "<a href='library/delimg.php?ID=".$row['ID']."&nam=".$indimg[$i]."&FN=s'>Delete</a>";
	echo "</tr>";
	
	/*echo "<td>".$i."</td>";
	$gh=$i+1;
	echo "<td>".$gh."</td>";
	*/
/*	}
	}
	echo "</table>";
	}*/
?>
</td>

  </tr>
  <tr>
    <td>Business</td>
    <td><input name="phbusiness" type="text" value="<?php echo $row['BusinessPhone'];?>" width="250"/></td>
    
    </tr>
  <tr>
    <td>Home</td>
    <td><input name="phhome" type="text" value="<?php echo $row['HomePhone'];?>" width="250"/></td>
    </tr>
  <tr>
    <td>Business Fax </td>
    <td><input name="phbusinessfax" type="text" value="<?php echo $row['BusinessFax'];?>" width="250"/></td>
    </tr>
  <tr>
    <td>Mobile</td>
    <td><input name="phmobile" type="text" value="<?php echo $row['MobilePhone'];?>" width="250"/></td>
    </tr>
  <tr>
    <td><strong>Address</strong></td>
    <td>&nbsp;</td>
    </tr>
  <tr>
    <td>Business</td>
    <td><label>
      <textarea name="addrbusiness" rows="4" style="width: 250px"><?php echo $row['BusinessStreet'];?></textarea>
    </label></td>
    </tr>
  <tr>
    <td>Home</td>
    <td><textarea name="addrhome" rows="4" style="width: 250px"><?php echo $row['HomeStreet'];?></textarea></td>
    </tr>
  <tr>
    <td>Other</td>
    <td><textarea name="addrother" rows="4" style="width: 250px"><?php echo $row['OtherStreet'];?></textarea></td>
    </tr>
	<tr>
    <td>Categories</td>
    <td><input name="Categories" type="text" value="<?php echo $row['Categories'];?>" width="250"/></td>
    
  </tr>
  <tr>
    <td>	</td>
    
    <td colspan="2"></td>
  </tr>
  
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td colspan="2"></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td colspan="3" rowspan="6">
	</td>
    </tr>
  <tr>
    <td>&nbsp;</td>
    </tr>
  <tr>
    <td>&nbsp;</td>
    </tr>
  <tr>
    <td>&nbsp;</td>
    </tr>
  <tr>
    <td>&nbsp;</td>
    </tr>
  <tr>
    <td>&nbsp;</td>
    </tr>
</table>
</form>
<br>
<?

include 'library/closedb.php';
?>
<blockquote>&nbsp;</blockquote>
</body>
</html>
Return current item: PHP MySQL Address Book