Results 1 to 5 of 5

Thread: editing mysql info

  1. #1
    Join Date
    Aug 2009
    Posts
    399
    Thanks
    42
    Thanked 4 Times in 4 Posts

    Default editing mysql info

    hello,
    I wonder if it is possible to edit info from mysql.
    I know how to update info... But if I want to edit it, i have to call it, then show in editor or something else idk how i can do this...
    Thanks... (btw, if you need more info, ask)

  2. #2
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default

    Sure you do. You know how to call the info and update the info. Basically, just call the info, assign it to a variable, place it into a textarea with a submit button at the bottom of the page and you know what to do after that.

    First page:
    Code:
    <?php include 'dbinfo.php';
    $topic = "select summary, date from tablename where ID = 4";
    $topic_res = mysql_query($verify_topic, $conn) or die(mysql_error());
    $add_info = mysql_fetch_array($get_addresses_res)) {
               $ID         = $add_info['ID'];
               $date       = $add_info['date'];
               $summary    = $add_info['summary'];
       }?><form action="/submitdata.php" method="post" name="editform">
    <textarea name="summary" cols=75 rows=25><?php print htmlentities($summary) ; ?></textarea>
    <p><input type="submit" name="newbutton" value="Submit Review">
    and then in submitdata.php:
    PHP Code:
    <?php
    include '../include/dbstuff.php';
      
    $newbutton=$_POST['newbutton'];
      
    $ID          $_POST['ID'];
      
    $date        $_POST['date'];
      
    $summary     $_POST['summary'];
      
    $query       "UPDATE tablename SET ID='$ID',date='$date',summary='$summary',image='$image' WHERE ID='$ID'";
      
    $result      mysql_query($query) or die ("Couldn't execute query.");
    ?>
    You have all of the info you need to do this from earlier questions you asked, but sometimes putting it all together is not always immediately understood. You should take a little more time to put what you know together before giving up and seeking help.

    PS Make sure you use cookies or sessions so that only the people you allow to use the page can do so. Also process your data to keep malicious (bad) data from being submitted.
    Last edited by james438; 11-26-2009 at 12:21 AM.
    To choose the lesser of two evils is still to choose evil. My personal site

  3. #3
    Join Date
    Aug 2009
    Posts
    399
    Thanks
    42
    Thanked 4 Times in 4 Posts

    Default

    Thanks... Hope this will work.

  4. #4
    Join Date
    Aug 2009
    Posts
    399
    Thanks
    42
    Thanked 4 Times in 4 Posts

    Default

    It works, but one thing left...
    I get text, but it is shown like this:
    PHP Code:
    J 63;s 71;  3;kelti darbai atliekami per 6-24h.<br>Ta 69;iau  3;vykus ir netik 79;toms prie&#382;astims, gali užsit&# 281;sti ir ilgiau.<br>B 63;kite kantr&# 363;s :D 
    I entered some spaces to show code for lithuanian letters.
    As you can see I use Lithuanian language
    and all br's are seen... how I can get nice output?
    Thanks.

  5. #5
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default

    I need more information. When you are gather the information and you want it to be shown without the line breaks (br) are you submitting the the content with line breaks or are they appearing out of nowhere?

    What I do with my content editing programs is I submit the data to the database with newlines as opposed to line breaks then when the content is retrieved the code looks nice. It looks like

    Code:
    This is some text.
    more text.
    
    A few more lines.
    as opposed to this which uses linebreaks:
    Code:
    This is some text.<br>more text.<br><br>A few more lines.
    If I want to echo or print the data from my database for general viewing as opposed to viewing it in a textarea like this program does I retrieve the content and reformat it and then display the formatted text. It looks something like
    Code:
    $content=str_replace("\r\n","<br>",$content);
    I also like to use
    Code:
    $content=str_replace("  ","&nbsp;&nbsp;",$content);
    because when browsers display data they tend to condense two or more consecutive spaces. This will display them again.
    To choose the lesser of two evils is still to choose evil. My personal site

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •