Location: PHPKode > scripts > eNetman > enetman-20050830/enetman/html/edit.php
<?
echo "<TABLE width='80%' cellspacing=0 border=0 cellpadding=0 align='center'>";
echo "<tr>";
echo "<td>";

$query = "SELECT * FROM maindata WHERE ID=$ID";

$result = mysql_query($query);

echo "<form name='updatemain' method='post' action='index.php?page=edit.php&view=$view&ID=$ID'>\n";
echo "<input type='hidden' name='action' value='update,main,$ID'>\n";
echo "<table bgcolor='000000' cellpadding=0 border=0 cellspacing=0 align='center' width='100%'>\n";
echo "\t<tr>\n";
echo "\t\t<td>\n";
echo "\t\t\t<table cellpadding=0 border=0 cellspacing=1 width='100%'>\n";

$num = mysql_num_fields($result);

echo "\t\t\t\t<tr>\n";
echo "\t\t\t\t\t<td colspan=$num align='center' bgcolor='#D3DCE3'><h3><b>Profile</b></td>\n";
echo "\t\t\t\t</tr>\n";

echo "\t\t\t\t<tr>\n";
echo "\t\t\t\t\t<td colspan=$num align='center' bgcolor='#CCCCCC'><img src='' width=1 height=1></td>\n";
echo "\t\t\t\t</tr>\n";

$n=0;
$line = mysql_fetch_array($result, MYSQL_ASSOC);
foreach ($line as $col_value) {
	$title = mysql_field_name($result,$n);
	if($title == "ID") {
		echo "\t\t\t\t<tr>\n";
		echo "\t\t\t\t\t<td width='30%' bgcolor='#FFFFFF'>&nbsp;&nbsp;<b>$title</b></td><td bgcolor='#FFFFFF'>&nbsp;&nbsp;$col_value</td>\n";
		echo "\t\t\t\t</tr>\n";
	} elseif ($title == "Status") {
        	echo "\t\t\t\t<tr>\n";
                echo "\t\t\t\t\t<td bgcolor='#FFFFFF'>&nbsp;&nbsp;<b>$title</b></td><td bgcolor='#FFFFFF'>&nbsp;&nbsp;<select name='$title'>\n<option value='Active' ";
		if($col_value == "Active") { echo "selected"; }
		echo ">Active</option>\n";
		echo "<option value='Inactive'";
		if($col_value == "Inactive") { echo "selected"; }
		echo ">Inactive</option>\n";
                echo "\t\t\t\t</tr>\n";
 	} elseif ($title == "URL"){
		if($col_value) {
			if(preg_match("/http:\/\//i",$col_value)) {
				echo "\t\t\t\t<tr>\n";
				echo "\t\t\t\t\t<td bgcolor='#FFFFFF'>&nbsp;&nbsp;<b>$title</b></td><td bgcolor='#FFFFFF'>&nbsp;&nbsp;<input type='text' class=\"frmStyle\" name='$title' value='$col_value'>&nbsp;&nbsp;<font color='#808080'>[<a href='$col_value' class='ilink' target='blank'>follow link</a>]</font>\n";
				echo "\t\t\t\t</tr>\n";
			} else {
				echo "\t\t\t\t<tr>\n";
				echo "\t\t\t\t\t<td bgcolor='#FFFFFF'>&nbsp;&nbsp;<b>$title</b></td><td bgcolor='#FFFFFF'>&nbsp;&nbsp;<input class='frmStyle' type='text' name='$title' value='$col_value'>&nbsp;&nbsp;<font color='#808080'>[<a href='http://$col_value' class='ilink' target='blank'>follow link</a>]</font>\n";
				echo "\t\t\t\t</tr>\n";
			}
		} else {
				echo "\t\t\t\t<tr>\n";
				echo "\t\t\t\t\t<td bgcolor='#FFFFFF'>&nbsp;&nbsp;<b>$title</b></td><td bgcolor='#FFFFFF'>&nbsp;&nbsp;<input class='frmStyle' type='text' name='$title' value='$col_value'>\n";
				echo "\t\t\t\t</tr>\n";
		}
	} elseif ($title != "dataType") {
		echo "\t\t\t\t<tr>\n";
                echo "\t\t\t\t\t<td bgcolor='#FFFFFF'>&nbsp;&nbsp;<b>$title</b></td><td bgcolor='#FFFFFF'>&nbsp;&nbsp;<input class='frmStyle' type='text' name='$title' value='$col_value'>\n";
                echo "\t\t\t\t</tr>\n";
	}
	$n++;
}

echo "\t\t\t\t<tr>\n";
echo "\t\t\t\t\t<td colspan=2 align='center' bgcolor='#FFFFFF'><input type='button' value='Update' class='frmStyle' onClick='updatemain.submit();'></td>\n";
echo "\t\t\t\t</tr>\n";
echo "\t\t\t</table>\n";
echo "\t\t</td>\n";
echo "\t</tr>\n";
echo "</table>\n";
echo "</form>";

mysql_free_result($result);

echo "</td></tr><tr><td colspan=5>&nbsp;</td></tr><tr><td colspan=5 bgcolor='cccccc'><img src='' width='1' height='1'></td></tr>    <tr><td colspan=5>&nbsp;</td></tr><tr><td colspan=5 valign='top'>";

$query = "SELECT contacts.Name, phone.Number, contacts.Extention, phone.Main, phone.ID FROM phone LEFT JOIN ";
$query = $query . "contacts ON phone.ID = contacts.ID WHERE (((phone.linkID)=$ID)) ORDER BY phone.Main";

$result = mysql_query($query);

$num = mysql_num_fields($result) + 1;
$colspan = $num + 1;
$rnum = 0 ;

echo "<table bgcolor='000000' cellpadding=0 border=0 cellspacing=0 align='center' width='100%'>\n";
echo "\t<tr>\n";
echo "\t\t<td>\n";
echo "\t\t\t<table cellpadding=0 border=0 cellspacing=1 width='100%'>\n";

echo "\t\t\t\t<tr>\n";
echo "\t\t\t\t\t<td colspan=$colspan align='center' bgcolor='#D3DCE3'><h3><b>Phone Numbers</b></td>\n";
echo "\t\t\t\t</tr>\n";

echo "\t\t\t\t<tr>\n";
echo "\t\t\t\t\t<td colspan=$num align='center' bgcolor='#CCCCCC'><img src='' width=1 height=1></td>\n";
echo "\t\t\t\t</tr>\n";

echo "\t\t\t\t<tr>\n";
while($rnum != $num) {
        $title = mysql_field_name($result, $rnum);
        if(($title != "ID") && ($title != "linkID")) {
                echo "\t\t\t\t\t<td bgcolor='ffffff' align='center'><b>$title</b></td>\n";
        }
        $rnum++;
}
echo "\t\t\t\t\t<td bgcolor='ffffff'>&nbsp;</td>\n";
echo "\t\t\t\t</tr>\n";

echo "\t\t\t\t<tr>\n";
echo "\t\t\t\t\t<td colspan=$colspan bgcolor='#CCCCCC'><img src='' width='1' height='2'></td>\n";
echo "\t\t\t\t</tr>\n";

$color = "#FFADAE";

echo "\t\t\t\t<tr>\n";
echo "<form name='addphone' method='post' action='index.php?page=edit.php&view=$view&ID=$ID'>\n";
echo "<input type='hidden' name='action' value='add,phone'>\n";

$rnum = 0;
while($rnum != $num) {
        $title = mysql_field_name($result, $rnum);               
        if(($title != "ID") && ($title != "linkID")) {
		if($title == "Main") {
			echo "\t\t\t\t\t<td bgcolor='#FFFFFF' align='center'><input type='checkbox' name='$title' value='true'></td>\n";			
		} elseif($rnum != $num-1) {
			echo "\t\t\t\t\t<td bgcolor='#FFFFFF' align='center'><input class='frmStyle' type='text' name='$title'></td>\n";
		}
        } 
        $rnum++;                
}

echo "<td colspan=2 align='center' bgcolor='#FFFFFF'><input type='button' value='Add' class='frmStyle' onClick='addphone.submit();'></td>\n";
echo "</form>";
echo "</tr>";

$result = mysql_query($query);
$num = mysql_num_rows($result);

if($num) {
	echo "\t\t\t\t<tr>\n";
	echo "\t\t\t\t\t<td colspan=$colspan bgcolor='#CCCCCC'><img src='' width='1' height='2'></td>\n";
	echo "\t\t\t\t</tr>\n";
}

while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
	$selected = "<input type='checkbox' name='Main' value='true' disabled checked>";
	if($line[Main] != "true") { $selected = "<input type='checkbox' name='Main' value='true'>"; }
	echo "\t\t\t\t<tr>\n";
	echo "<form name='updatephone$line[ID]' method='post' action='index.php?page=edit.php&view=$view&ID=$ID'>\n";
	echo "<input type='hidden' name='action' value='update,phone,$line[ID]'>\n";
	$n=0;
	foreach ($line as $col_value) {
		$title = mysql_field_name($result, $n);
		if(($title != "ID") && ($title != "linkID")){
			if($title == "Main") {
	                       	echo "\t\t\t\t\t<td bgcolor='$color' align='center'>$selected</td>\n";			
			} else {
                       		echo "\t\t\t\t\t<td bgcolor='$color' align='center'>&nbsp;<input class='frmStyle' type='text' name='$title' value='$col_value'>\n";
			}
		}
		$n++;
	}
	echo "<td colspan=2 align='center' bgcolor='$color'><input type='button' value='Update' class='frmStyle' onClick='updatephone$line[ID].submit();'>&nbsp;<input type='button' value='Delete' class='frmStyle'onClick=\"deleteme('index.php?page=edit.php&view=$view&ID=$ID','phone','$line[ID]');\"></td>\n";
	echo "</form>\n";
        echo "\t\t\t\t</tr>\n";
	$color = "#FFFFFF";
}
echo "\t\t\t</table>\n";
echo "\t\t</td>\n";
echo "\t</tr>\n";
echo "</table>\n";

mysql_free_result($result);

modulesCheck($view);

echo "</td></tr></table>";
echo "<br>";
echo "<center><input type='button' value='Delete' onClick=\"deletefull('index.php?view=$view','main','$ID');\" 
class='frmStyle'></center>";


mysql_close($link);

?>
Return current item: eNetman