i m newbie in web development plz help me to sort out the problem..
the problem is: in edit.php when control enters in if condition it never goes to else when i press the edit button.
i want to get id from view.php and display category name in edit.php textbox so i can change the category name by pressing edit button.
view.php
<?
require("Datab.class.php");
$db = new Datab("localhost", "root", "intaha", "subc");
$db->connect();
$result = $db->query("select * from category");
?>
<table border="1" cellpadding="0">
<?
if(mysql_num_rows($result)){
while($rows = mysql_fetch_row($result)){ ?>
<tr>
<td><? echo $rows[0]; ?></td>
<td><? echo $rows[1]; ?></td>
<td><a href="edit.php?id=<?=$rows[0]?>">edit</a></td>
<td><a href="delete.php?id=<?=$rows[0]?>">delete</a></td>
</tr>
<?
}
}
?> </table>
edit.php
<html>
<head>
<title></title>
</head>
<body>
<?php
require("Datab.class.php");
$db = new Datab("localhost", "root", "intaha", "subc");
$db->connect();
$id = $_GET['id'];
echo "hello this is upper.... $id";
$result = $db->query("select name from category where category_id = $id");
$name = "";
if(mysql_num_rows($result) > 0){
while($rows = mysql_fetch_row($result)){
$name = $rows[0];
}
}
if(!isset($_POST['submit'])){
echo "<br> in !isset condition..... <br> ";
?>
<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
<input type="text" name="cat_name" value= "<? echo $name; ?>" />
<input type="submit" name="submit" value="edit" />
</form>
<?
}else{
echo "<br> in else condition..... <br> ";
$uname= $_POST['cat_name'];
echo "name = " .$uname;
echo "in id = " . $id . " ";
$result = $db->query("update category SET name = '$uname' where category_id = $id");
echo "Category name changed ";
}
?>
</body>
</html>