I'm trying to make AdminPanel In PHP MYSQL. Now I'm at editing function. I want to edit my Letter, that I have already added in SQL.
I have 3 php file.
edit.php. There I'm connecting to Data Base and I'm taking out "title", "description"
<?php
$result = mysql_query ("SELECT * FROM C_lessons", $db);
$row = mysql_fetch_array ($result);
do{
printf ("
<table class='lesson_table' width='840px' >
<tr><td>
<div class='lesson'>
<a href='editing.php?id=%s'>
%s <br>
აღწერა: %s </a>
</div>
</td></Tr> </table> ", $row["id"], $row["title"], $row["description"]);
} while ($row = mysql_fetch_array ($result));
?>
editing.php
<?php
$id = $_GET['id'];
$result = mysql_query ("SELECT * FROM C_lessons WHERE id='$id'", $db);
$row = mysql_fetch_array ($result);
?>
<form method="post" action="edited.php" >
<table width="100%" >
<tr>
<td width="15%"> <em><strong>title</strong></em></td>
<td><input type="text" name="title" value="<?php echo $row['title'] ?>"> </td>
</tr>
<tr>
<td> <em><strong>description</strong></em></td>
<td><textarea name="description" cols="70" rows="10" > <?php echo $row['description']; ?> </textarea></td>
</tr>
<tr>
<td> <em><strong>text</strong></em></td>
<td><textarea name="text" cols="70" rows="20" > <?php echo $row['text']; ?> </textarea></td>
</tr>
<tr>
<td><input name="add" type="submit" value="textს add"></td>
</tr>
</table>
</form>
edited.php
<?php
if (isset($_POST['title'])) {$title = $_POST['title'];}
else {echo "line 1 Var Isset Error"; exit();}
if (isset($_POST['description'])) {$description = $_POST['description'];}
else {echo "line 2 Var Isset Error"; exit();}
if (isset($_POST['text'])) {$text = $_POST['text'];}
else {echo "line 3 Var Isset Error"; exit();}
?>
<?php
$db = mysql_connect ("mysql6.000webhost.com","a3729878_vakho","******");
mysql_select_db ("a3729878_site",$db);
if (isset($title) && isset($description) && isset($text)) // line "if Var Is not set"
if ($title!=="" && $title!=="" && $text!=="")
{
$damateba = mysql_query ("UPDATE C_lessons set title = '$title', description='$description', text='$text' WHERE id='$id'");
if($damateba =='true'){ echo "EDITED";}
else {echo "MYSQL ERROR NONT EDITED;}
}
else if ($title=="" || $description=="" || $text=="") {echo "you should fill all the grap"; }
else {echo " line Var Isset Error,"; } // else of line "if Var is not set"
?>
I have problems with this code:
$damateba = mysql_query ("UPDATE C_lessons set title = '$title', description='$description', text='$text' WHERE id='$id'");
edited.php dont know what is '$id'. But If I write, for example, id=27 everything works. so i wont to make something to tell edited.php what is $id. $id knows only editing.php, does not it?
Thanks a lot :)


Sign In
Create Account


Back to top









