Hi,
I want to update the status (pending or closed). It is not working, please help me.
Rgds
Sridsam
PHP Code :
<table border="1" width="75%" cellpadding="2" cellspacing="2">
<tr>
<td align="center">ID</td>
<td align="center">DATE</td>
<td align="center">STATUS</td>
<td align="center">REMARKS</td>
</tr>
<HEAD>
<STYLE type="text/css">
<!--
.red { color:red }
.green { color:darkgreen }
-->
</STYLE>
</HEAD>
<?php
//connect to mysql
//change user and password to your mySQL name and password
mysql_connect("localhost","root","nandanam");
//select which database you want to edit
mysql_select_db("times");
//If cmd has not been initialized
if(!isset($cmd))
{
//display all the pending ids
$result = mysql_query("SELECT id,date,status,remarks FROM elog ORDER BY id");
//run the while loop that grabs all the pending IDs
while($r=mysql_fetch_array($result))
{
if($r['status']=='Pending') $color = '#FF6699';//sort of red
else $color = '#66FF99';//sort of green
//grab the title and the ID of the news
echo "<tr>";
echo "<td align=center><a href='eedit.php?cmd=edit&id=$r[0]'>$r[0]</td>" ;
echo "<td align=center>$r[1]</td>";
echo "<td align=center bgcolor=$color> $r[2]</td>";
echo "<td align=left>$r[3]</td>";
echo "</tr>";
}
}
?>
<html>
<form><INPUT TYPE="button" VALUE="Main Menu" onClick="history.go(-1);return true;"> </FORM>
</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="estatus1.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>
<td width="10%"> Change Status : </td>
<td width="100%">
<Input type = 'Radio' Name ='status' value= 'Pending'>Pending
<Input type = 'Radio' Name ='status' value= 'Closed'>Closed
</td>
</tr>
<br>
<hr>
<input type="hidden" name="cmd" value="edit">
<input type="submit" name="submit" value="submit">
<form><INPUT TYPE="button" VALUE="Log Details" onClick="history.go(-1);return true;"> </FORM>
<hr>
</form>
<? }
?>
<?php
if ( isset( $POST["submit"] , $POST['id'] ) )
{
$idtoupdateby = intval( $POST['id'] );
$status = $POST['status'];
$sql = "UPDATE elog SET status=$status WHERE id='$idtoupdateby'";
$result = mysql_query( $sql );
echo "Thank you! log entry updated.";
}
}
?>