Dear all,
I want to change the status (pending or closed) after selecting a particular ID.
After selecting the ID, radio button (pending & closed) & it has to confirm (yes or no) to change the status. Pl help me.
Tks
Sridsam
Code:
<html>
<body>
<?php
$username="rrrr";
$password="nnnnn";
$database="ttttt";
mysql_connect(localhost,$username,$password);
mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM elog";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
?>
<p align="center"><b><font face="Arial, Helvetica, sans-serif" size="5" color="blue">e-LOG Details</font></b></p>
<table width="98%" border="1" align="center" <font face="Arial, Helvetica, sans-serif" size=2"></font>
<tr>
<th><font face="Arial, Helvetica, sans-serif" size="2">ID</font></th>
<th><font face="Arial, Helvetica, sans-serif" size="2">STATUS</font></th>
<th><font face="Arial, Helvetica, sans-serif" size="2">DATE</font></th>
<th><font face="Arial, Helvetica, sans-serif" size="2">LOCATION</font></th>
<th><font face="Arial, Helvetica, sans-serif" size="2">CATETORY</font></th>
<th><font face="Arial, Helvetica, sans-serif" size="2">REMARKS</font></th>
</tr>
<?php
$i=0;
while ($i < $num) {
$f1=mysql_result($result,$i,"id");
$f2=mysql_result($result,$i,"date");
$f3=mysql_result($result,$i,"location");
$f4=mysql_result($result,$i,"category");
$f5=mysql_result($result,$i,"remarks");
$f6=mysql_result($result,$i,"status");
?>
<tr>
<td><font face="Arial, Helvetica, sans-serif size=2 /n"><?php echo $f1; ?> </font></td>
<td><font face="Arial, Helvetica, sans-serif /n"><?php echo $f6; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif /n /n /n"><?php echo $f2; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif /n"><?php echo $f3; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif /n"><?php echo $f4; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif /n"><?php echo $f5; ?></font></td>
</tr>
<?php
$i++;
}
?>
</body>
</html>
<?php
if($_GET["cmd"]=="edit" || $_POST["cmd"]=="edit")
{
if (!isset($_POST["submit"]))
{
$pid = $_GET["id"];
$sql = "SELECT * FROM elog WHERE id=$pid";
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
?>
<form action="eviewall.php" method="post">
<input type=hidden name="id" value="<?php echo $myrow["id"] ?>">
<hr>
Case ID : <?php echo $myrow["id"] ?> <br>
Date : <?php echo $myrow["date"] ?> <br>
Location : <?php echo $myrow["location"] ?><br>
Name : <?php echo $myrow["name"] ?><br>
Category : <?php echo $myrow["category"] ?> <br>
Remarks : <?php echo $myrow["remarks"] ?><br>
Status : <?php echo $myrow["status"] ?> <br>
<hr>
Followup-1 :<INPUT TYPE="TEXT" NAME="followup1" VALUE="<?php echo $myrow["followup1"] ?>" SIZE=150> <br>
Followup-2 :<INPUT TYPE="TEXT" NAME="followup2" VALUE="<?php echo $myrow["followup2"] ?>" SIZE=150> <br>
Followup-3 :<INPUT TYPE="TEXT" NAME="followup3" VALUE="<?php echo $myrow["followup3"] ?>" SIZE=150> <br>
Followup-4 :<INPUT TYPE="TEXT" NAME="followup4" VALUE="<?php echo $myrow["followup4"] ?>" SIZE=150> <br>
Followup-5 :<INPUT TYPE="TEXT" NAME="followup5" VALUE="<?php echo $myrow["followup5"] ?>" SIZE=150> <br>
<br>
Is Pending : <INPUT TYPE = "Radio" Name ="status1" value="Pending">Yes
<INPUT TYPE = "Radio" Name ="status1" value="Closed">No <br>
<br>
<input type="hidden" name="cmd" value="edit">
<input type="submit" name="submit" value="submit">
<input type="submit" value="Close" onClick="javascript:window.close()">
</form>
<? } ?>
<?php
if ( isset( $_POST["submit"] , $_POST['id'] ) )
{
$idtoupdateby = intval( $_POST['id'] );
$followup1 = isset( $_POST["followup1"] )? "'" . mysql_real_escape_string( $_POST["followup1"] ) . "'" : 'NULL';
$followup2 = isset( $_POST["followup2"] )? "'" . mysql_real_escape_string( $_POST["followup2"] ) . "'" : 'NULL';
$followup3 = isset( $_POST["followup3"] )? "'" . mysql_real_escape_string( $_POST["followup3"] ) . "'" : 'NULL';
$followup4 = isset( $_POST["followup4"] )? "'" . mysql_real_escape_string( $_POST["followup4"] ) . "'" : 'NULL';
$followup5 = isset( $_POST["followup5"] )? "'" . mysql_real_escape_string( $_POST["followup5"] ) . "'" : 'NULL';
$status1 = isset( $_POST["status1"]);
$sql = "UPDATE elog SET status=$status1,followup1=$followup1,followup2=$followup2,followup3=$followup3,followup4=$followup4,followup5=$followup5 WHERE id='$idtoupdateby'";
$result = mysql_query( $sql );
echo "Thank you! log entry updated.";
}
}
?>