Your IP : 216.73.216.40


Current Path : /var/www/html/mmishra/ilight/
Upload File :
Current File : /var/www/html/mmishra/ilight/elcommon.inc

<h3>Common Areas</h3>
<center>

<?php
$tbl = "el_licensee";

$id = $_REQUEST["id"];
$flatno = $_POST["flatno"];
$fullname = $_POST["fullname"];
$designation = '';
$email = 'ilight@iiita.ac.in';
$category = 'Common';
$sharing = 'Yes';
$external = 'No';
$subsidy = 0;
$dated = date("Y-m-d");

if ($_POST["submit"] == 'SAVE') {
	if (mysql_num_rows(mysql_query("select * from $tbl where id=$id"))) {
		mysql_query("update $tbl set flatno='$flatno',fullname='$fullname',designation='$designation',
		email='$email',category='$category',sharing='$sharing',external='$external',subsidy=$subsidy,dated=now() 
		where id=$id");
	} else {
                mysql_query("insert into $tbl(flatno,fullname,designation,email,category,sharing,external,subsidy,dated) 
		values('$flatno','$fullname','$designation','$email','$category','$sharing','$external',$subsidy,now())");
	}
}

echo "<table width='50%' border='1' style='border-collapse: collapse'>
<tr><th>No</th><th>SiteNo</th><th>Location</th></tr>
<tr valign='top'><td>New</td>";

if (!$id) {
        echo "<th><input type='text' name='flatno' size='10' value=''></th>
        <td nowrap><input type='text' name='fullname' size='50' value=''>
        <input type='hidden' name='id' value='0'></td></tr>
        <tr><th colspan='3'><input type='submit' name='submit' value='SAVE'></th>";
} else {
        echo "<td colspan='2'><a href='?pg=$pg&id=#new'>Site/Flat</a></td>";
}
echo "</tr>";

//existing records
//$rs = mysql_query("select * from $tbl order by flatno");
$rs = mysql_query("select *,
    least(
      case when locate('0', flatno)>0 then locate('0', flatno) else length(flatno)+1 end,
      case when locate('1', flatno)>0 then locate('1', flatno) else length(flatno)+1 end,
      case when locate('2', flatno)>0 then locate('2', flatno) else length(flatno)+1 end,
      case when locate('3', flatno)>0 then locate('3', flatno) else length(flatno)+1 end,
      case when locate('4', flatno)>0 then locate('4', flatno) else length(flatno)+1 end,
      case when locate('5', flatno)>0 then locate('5', flatno) else length(flatno)+1 end,
      case when locate('6', flatno)>0 then locate('6', flatno) else length(flatno)+1 end,
      case when locate('7', flatno)>0 then locate('7', flatno) else length(flatno)+1 end,
      case when locate('8', flatno)>0 then locate('8', flatno) else length(flatno)+1 end,
      case when locate('9', flatno)>0 then locate('9', flatno) else length(flatno)+1 end) pos
  from $tbl where category='Common' order by left(flatno, pos-1), mid(flatno, pos, length(flatno)-pos+1)+0");

while ($o = mysql_fetch_object($rs)) {
	$i++;
	echo "<tr valign='top'><td><a href='?pg=$pg&id=$o->id#l$i' name='l$i'>$i</a></td>";
	if ($o->id == $id) {
		echo "
		<th><input type='text' name='flatno' size='10' value='$o->flatno'></th>
		<td nowrap><input type='text' name='fullname' size='50' value='$o->fullname'>
		<input type='hidden' name='id' value='$o->id'></td></tr>
		<tr><th colspan='2'><input type='submit' name='submit' value='SAVE'></th>
		<th><input type='submit' name='submit' value='DELETE'></th>";
	} else {
		echo "<th>$o->flatno</td><td nowrap>Name $o->fullname</td>";
	}
	echo "</tr>";
}
echo "</table>
</center>";
?>