Jump to content

Edit via PHP


lostprophetpunk

Recommended Posts

I have been working on a way to edit articles in my blog system.

 

I have come across a problem though. I get the article id that is set in the link, and then display the results in a form. I then set variables that contain the information in the database. I then echo the variables as values in the form. I can get the title to work but the thing is that the data in the database isn't all being put in the variable, as only part of it shows in the form...

 

Below is the code for my edit page...

<?php

  include("../connection.php");
  
  include("../header.php");
  
  if($session_name){

    $editid = $_GET['id'];
    $editid = mysql_real_escape_string( $editid );

    $Query = mysql_query(" SELECT * FROM articles WHERE article_id='$editid' ");
    $Data = mysql_fetch_array( $Query );
    
    $title = $Data['article_name'];
    $entrye = $Data['entry'];
  
  echo "<div class='mainc'>\n";
  echo "<div class='maintop'>Edit Article</div>\n";
  echo "<div class='main'>\n";     
      echo "<form name=\"addpost\" method=\"post\" action=\"postd.php\">\n";
      echo "Title  <input type=\"text\" name=\"name\" value=\"$title\"><br />\n";
      echo " <textarea rows=\"20\" cols=\"60\" name=\"entry\" wrap=\"virtual\" onkeyup=\"f=document.addpost;f.char_count.value=f.entry.value.length;\" value=\"$entrye\"></textarea>\n";
      echo "<input type=\"readonly\" name=\"char_count\" size=\"2\" /><br />\n";
      echo "<input type=\"submit\" name=\"submit\" value=\"Post\"><br />\n";
      echo "</form>\n";
      
      }else {
      echo "You have to be logged in to view this page.<br /><br />Redirecting you to the home page...\n";
      echo "<meta http-equiv=\"refresh\" content=\"3;url=../\" />\n";
      }  
  echo "</div>\n";
  echo "<div class='mainbottom'></div>\n";
  echo "</div>\n";
  include("../footer.php");

?>

 

I have been thinking on how to fix this but returned nothing.

Link to comment
Share on other sites

try this if dosent work use a proper for loop....... with braces.........

 

<?php

  include("../connection.php");
  
  include("../header.php");
  
  if($session_name){

    $editid = $_GET['id'];
    $editid = mysql_real_escape_string( $editid );

    $Query = mysql_query(" SELECT * FROM articles WHERE article_id='$editid' ");
    $Data = mysql_fetch_assoc( $Query );
    
    $title = $Data['article_name'];
    $entrye = $Data['entry'];
  
  echo "<div class='mainc'>\n";
  echo "<div class='maintop'>Edit Article</div>\n";
  echo "<div class='main'>\n";     
      echo "<form name=\"addpost\" method=\"post\" action=\"postd.php\">\n";
      echo "Title  <input type=\"text\" name=\"name\" value=\"$title\"><br />\n";
      echo " <textarea rows=\"20\" cols=\"60\" name=\"entry\" wrap=\"virtual\" onkeyup=\"f=document.addpost;f.char_count.value=f.entry.value.length;\" value=\"$entrye\"></textarea>\n";
      echo "<input type=\"readonly\" name=\"char_count\" size=\"2\" /><br />\n";
      echo "<input type=\"submit\" name=\"submit\" value=\"Post\"><br />\n";
      echo "</form>\n";
      
      }else {
      echo "You have to be logged in to view this page.<br /><br />Redirecting you to the home page...\n";
      echo "<meta http-equiv=\"refresh\" content=\"3;url=../\" />\n";
      }  
  echo "</div>\n";
  echo "<div class='mainbottom'></div>\n";
  echo "</div>\n";
  include("../footer.php");

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.