php - The edit form in the same page won't show up when I click the EDIT link -


i trying update or edit data database don't want edit page in page, want in same page can view different news user has added. form won't show when click edit link .

help me find what's wrong or missing?

here's edit_news.php

<?php  date_default_timezone_set('asia/manila'); include_once('db.php'); if($isset($_get['id'])) {     $id=$_get['id'];     if(isset($_post['edit'])) {      $title = $_post['title'];     $body = $_post['body'];     $date = date('y-m-d h:i:s');      $title = mysql_real_escape_string($title);     $body = mysql_real_escape_string($body);      $servername = "localhost";     $username="root";     $password = "";     $database = "zchs_alumni";     $connection = new mysqli($servername, $username, $password, $database);     if ($connection->connect_error) {         die("connection failed: " . $connection->connect_error);     }         $sql = ("update news set title = '$title', body = '$body', name = '$name', date = '$date' id='$id'")or die();         mysql_query($sql);         echo "<script type='text/javascript'>alert('changes saved!'); window.location.assign('/zchs-alumni/news.php');</script>";     } }?>  <?php if($isset($_get['id'])) {     $id=$_get['id'];     $query=mysql_query("select * news id='$id'");     while($row = mysql_fetch_array($query)) {         $title=$row['title'];         $body=$row['body']; ?>  <form action="" method="post"> <p>     <label for="title" id="title">title</label>     <input type="text" name="title" value="<?php echo $row['title']; ?>"/> </p><br/> <p>     <label for="body" id="body">body</label>     <input type="text" name="body" value="<?php echo $row['body']; ?>"/> </p><br/> <p>     <input type="submit" name="update" value="save changes" style="float: right"/> </p> </form> <?php        }   }?> 

and news.php news show , want editing of data take place.

<?php  mysql_connect("localhost", "root", "") or die(mysql_error());  mysql_select_db("zchs_alumni") or die(mysql_error()); $query = mysql_query("select * news order date desc limit $start, $limit");     while($row = mysql_fetch_array($query)) {  ?> <p> <span><h3><?php echo $row['title']; ?></h3></span></p> <p> <span><?php     $img = $row['photo'];         if($img != ""){             $image = 'news/'.$img;             echo '<center><img src="'.$image.'" width="750" height="350" alt=""></center>';         }     ?></span></p> <br/> <p> <span><?php echo $row['body']; ?></span></p> <br/> <p> <span><h6>posted @     <?php         $row_date = strtotime($row['date']);         echo date("f j, y, g:i a", $row_date);     ?></h6></span></p> <br/>  <p><span><a href="edit_news.php?id=<?php echo $row['id']; ?>"><span class="edit" title="edit">edit</span></a></p> <?php }  ?> 

i have seen these guys that. simple check if post variable defined if(isset($_post)) , if update submission, if not display form!


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -