Location: PHPKode > projects > PHP MySQL Address Book > addressbook/dtaildwabraaddressbook.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)
{
//$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`,`user_id`,`Department`,`BusinessPhone2`,`BusinessCountry`,`HomeCountry`,`OtherCountry`,`CompanyMainPhone`,`HomeFax`,`HomePhone2`,`PrimaryPhone`,`Birthday`,`Categories`,`Email3Address`,`Email2Address`,user_id,user_id2,updatedon FROM contacts where ID=" .$_GET['ID'];
mysql_query("SET NAMES 'utf8'");
mysql_query('SET CHARACTER SET utf8'); 
$result = mysql_query($query);
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$DOB = explode("/", trim($row['Birthday']));
	
	if (trim($DOB[0])!=="")
	{
	$mmonth=trim($DOB[0]);
	}
		if (trim($DOB[1])!=="")
	{
	$dday=trim($DOB[1]);
	}
	if (trim($DOB[2])!=="")
	{
	$yyear=trim($DOB[2]);
	}
	
	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="form1" name="wabraaddr" method="post">
  <table width="90%" border="0">
  <tr>
    <td width="9%">Full Name </td>
    <td width="29%">
	<table  border="0" cellspacing="0" cellpadding="0">
      <tr>
	   <td width="44"><input type="text" name="title" value= "<?php echo trim($row['Title']);?>" size="4"/></td>
        <td width="204"><input type="text" name="fullname" value= "<?php echo $row['FirstName'];?>" width="200"/></td>
      </tr>
    </table></td>

    <td width="11%">E-mail</td>
    <td width="42%"><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 width="9%">
	<?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='dtailsaveaddr.php?a=1';" />
	<?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>Email 2</td>
    <td><input type="text" name="Email2Address"value= "<?php echo $row['Email2Address'];?>" width="250"/>
	<?php 
	if (trim($row['Email2Address'])!=="")
	{

echo "<br><a href='mailto:".trim($row['Email2Address'])."'>" .trim($row['Email2Address'])."</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="submit" value="Add Image" onclick="form.action='dtailsaveaddr.php?a=0&adb=d';" />
	<?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>Email 3</td>
    <td><input type="text" name="Email3Address" value= "<?php echo $row['Email3Address'];?>" width="250"/>
	<?php 
	if (trim($row['Email3Address'])!=="")
	{

echo "<br><a href='mailto:".trim($row['Email3Address'])."'>" .trim($row['Email3Address'])."</a><br>";
	
	 }
	?></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=d' 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=d&mod=del'>Delete</a>";						//echo "<a href='library/delimg.php?ID=".$row['ID']."&nam=".$imgrow['imagename']."&FN=d'>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>Department </td>
    <td><input type="text" name="dept" value="<?php echo $row['Department'];?>" 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>
  </tr>
  <tr>
    <td><strong>Phone Numbers</strong> </td>
    <td><input type="hidden" name="addrid" value= "<?php echo $row['ID'];?>" /></td>
    <td style=" vertical-align: top;" colspan="2" rowspan="19"><textarea name="notes" rows="30" style="width: 450px"><?php echo $row['Notes'];?></textarea></td>
  </tr>
  <tr>
    <td>Business</td>
    <td><input name="phbusiness" type="text" value="<?php echo $row['BusinessPhone'];?>" width="250"/></td>
    </tr>
    <tr>
    <td>Business 2 </td>
    <td><input name="phbusinessphon2" type="text" value="<?php echo $row['BusinessPhone2'];?>" 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>Company MainPhone</td>
    <td><input name="CompanyMainPhone" type="text" value="<?php echo $row['CompanyMainPhone'];?>" 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>Home 2</td>
    <td><input name="HomePhone2" type="text" value="<?php echo $row['HomePhone2'];?>" width="250"/></td>
    </tr>
   <tr>
      <td>Home Fax</td>
    <td><input name="HomeFax" type="c" value="<?php echo $row['HomeFax'];?>" 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>Primary Phone</td>
    <td><input name="PrimaryPhone" type="text" value="<?php echo $row['PrimaryPhone'];?>" width="250"/></td>
    </tr>
  <tr>
    <td>Birthday</td>
	<td>
	<label>
			  <select name="dday">
			  <?php	
			  if (trim($row['Birthday'])=="" or trim($row['Birthday'])=="0/0/00")
			  {
echo "<option selected='selected'>0</option>";			  
			  }
			  foreach (range('1', '31') as $letter) {
			  if ($letter==$dday)
			  {
			  	echo "<option value=".$letter." selected='selected'>".$letter."</option>";
			  }
			  else
			  {
				echo "<option value=".$letter.">".$letter."</option>";
		    	}
}
				?>
  	          </select>
	    </label>
			  <label>
			  <select name="mmonth">
			  <?php	
			  if (trim($row['Birthday'])=="" or trim($row['Birthday'])=="0/0/00")
			  {
echo "<option selected='selected'>0</option>";			  
			  }
			  foreach (range('1', '12') as $letter) {
			  if ($letter==$mmonth)
			  {
			  	echo "<option value=".$letter." selected='selected'>".$letter."</option>";
			  }
			  else
			  {
				echo "<option value=".$letter.">".$letter."</option>";
		    	}
}
				?>
  	          </select>
			  </label>
			  <label>
			  <select name="yyear">
			  <?php	
			  if (trim($row['Birthday'])=="" or trim($row['Birthday'])=="0/0/00")
			  {
echo "<option selected='selected'>00</option>";			  
			  }
			  foreach (range('1850', '2150') as $letter) {
			  if ($letter==$yyear)
			  {
			  	echo "<option value=".$letter." selected='selected'>".$letter."</option>";
			  }
			  else
			  {
				echo "<option value=".$letter.">".$letter."</option>";
		    	}
}
				?>
  	          </select>
			  </label>
	
	
	<!--<input name="Birthday" type="text" value="<?php echo $row['Birthday'];?>" 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>
  Country  </td>
  <td><input name="buscntry" type="text" value="<?php echo $row['BusinessCountry'];?>" width="250"/></td>
  </tr>
  <tr>
    <td>Home</td>
    <td><textarea name="addrhome" rows="4" style="width: 250px"><?php echo $row['HomeStreet'];?></textarea></td>
    </tr>
  <tr>
  <td>Country</td>
  <td><input name="homcntry" type="text" value="<?php echo $row['HomeCountry'];?>" width="250"/></td>
  </tr>
  <tr>
    <td>Other</td>
    <td><textarea name="addrother" rows="4" style="width: 250px"><?php echo $row['OtherStreet'];?></textarea></td>
    </tr>
  <tr>
  <td>Country</td>
  <td><input name="othrcntry" type="text" value="<?php echo $row['OtherCountry'];?>" width="250"/></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>&nbsp;</td>
    <td colspan="2">&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td colspan="2">&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td colspan="3" rowspan="6">&nbsp;</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