here is my code..
<?php include "connect.php"?>
<?php connect_db() ?>
<?php
$com_id = $_POST['com_id'];
$com_name = $_POST['name'];
$com_matric = $_POST['matric'];
$com_email = $_POST['email'];
$com_yearofstudy = $_POST['yearofstudy'];
$com_position = $_POST['position'];
$sql="SELECT * FROM committee ORDER BY com_id DESC";
$result=mysql_query($sql);
?>
<?php
while($rows=mysql_fetch_array($result)) {// Start looping table row
?>
<html>
<head></head>
<body>
<form id="org_update" name="org_update" method="post" action="update_form.php">
<table>
<tr>
<td><strong>Name :</strong>:<?php echo $rows['com_name']; ?></td>
</tr>
<tr>
<td><strong>Matric :</strong><?php echo $rows['com_matric']; ?></td>
</tr>
<tr>
<td><strong>Email :</strong><?php echo $rows['com_email']; ?></td>
</tr>
<tr>
<td><strong>Year of Study :</strong><?php echo $rows['com_yearofstudy']; ?></td>
</tr>
<tr>
<td><strong>Position :</strong><?php echo $rows['com_position']; ?></td>
</tr>
<tr>
<td><input type="submit" value="Update" ></td>
</tr>
</table>
<input type="hidden" name="com_id" value="<?php echo $rows['com_id']; ?>" >
<input type="hidden" id="com_name" name="com_name" value="<?php echo $rows['com_name']; ?>" >
<input type="hidden" id="com_name" name="com_matric" value="<?php echo $rows['com_matric']; ?>" >
<input type="hidden" id="com_name" name="com_email" value="<?php echo $rows['com_email']; ?>" >
<input type="hidden" id="com_name" name="com_yearofstudy" value="<?php echo $rows['com_yearofstudy']; ?>" >
<input type="hidden" id="com_name" name="com_position" value="<?php echo $rows['com_position']; ?>" >
<td>
<a href="delete_cs.php?userID=<?php echo $row['com_id']?>"><img src="images/delete.jpg"></a>
</td>
</form>
</body>
</html>
<?php
}
mysql_close();
?>
update_form.php
<?php include "connect.php"?> <?php connect_db() ?> <?php $com_id = $_POST['com_id']; $com_name = $_POST['com_name']; $com_matric = $_POST['com_matric']; $com_email = $_POST['com_email']; $com_yearofstudy = $_POST['com_yearofstudy']; $com_position = $_POST['com_position']; echo $com_id; $sql="SELECT * FROM committee WHERE com_id='$com_id'"; $result=mysql_query($sql); ?> <html> <head></head> <body> <h3>Computer Science Committee</h3> <form id="cs_chart" name="cs_chart" method="post" action="update_cs.php"> <table> <tr> <td>Name: </td> <td><input type="text" name="com_name" value="<?php echo $com_name;?>"></td> </tr> <tr> <td>Matric: </td> <td><input type="text" name="com_matric" value="<?php echo $com_matric;?>"></td> </tr> <tr> <td>email: </td> <td><input type="text" name="com_email" value="<?php echo $com_email;?>"></td> </tr> <tr> <td>Year of Study: </td> <td><input type="text" name="com_yearofstudy" value="<?php echo $com_yearofstudy;?>"></td> </tr> <tr> <td>Position: </td> <td><input type="text" name="com_position" value="<?php echo $com_position;?>"></td> </tr> <tr> <td colspan="2"> <input type="submit" value="UPDATE"> </td> </tr> <input type="hidden" id="com_name" name="com_id" value="<?php echo $rows['com_id']; ?>" > </table> </form> </body> </html>
update_cs.php
<?php include "connect.php"?>
<?php connect_db() ?>
<?php
$com_id=$_POST['com_id'];
echo $com_id;
$com_name = $_POST['com_name'];
$com_matric = $_POST['com_matric'];
$com_email = $_POST['com_email'];
$com_yearofstudy = $_POST['com_yearofstudy'];
$com_position = $_POST['com_position'];
$sql ="UPDATE committee SET com_name='$com_name',com_matric='$com_matric',com_email='$com_email',com_yearofstudy='$com_yearofstudy',com_position = '$com_position'WHERE com_id = '$com_id'";
$result = mysql_query($sql);
if($result){
echo "Successful updated!<BR/>";
echo "<a href=cs_result.php>View your chart>";
exit();
}
else
{
echo "error";
}
mysql_close();
?>
delete_cs.php
<?php include "connect.php"?>
<?php connect_db() ?>
<?php
$com_id = $_GET['com_id'];
$sql = "DELETE FROM committee WHERE com_id = $com_id";
$result = mysql_query($sql);
if($result){
echo "<a href=cs_result.php>View your chart>";
exit();
}
else
{
echo "error";
}
mysql_close();
?>
in the end ..it turns our blank page and databases not updated ...
hope u all can help me out with tis.... thanks everyone ...

New Topic/Question
Reply



MultiQuote



|