Page 1 of 2 12 LastLast
Results 1 to 10 of 19
  1. #1
    Join Date
    Apr 2007
    Location
    england
    Posts
    536
    Tokens
    0

    Default PHP - Edit mySQL entries via webpage?

    I know how to display the data from a mySQL table, but how can I edit it via a webpage? Instead of going into phpMyAdmin you can edit it on a webpage. Is this possible?


    Selling DJ/Habbo layout, more info here.


  2. #2
    Join Date
    Nov 2006
    Posts
    1,939
    Tokens
    0

    Latest Awards:

    Default

    i dnt think you can.. buh am not sure.. ><"

  3. #3
    Join Date
    Apr 2007
    Location
    england
    Posts
    536
    Tokens
    0

    Default

    I'm pretty sure you can, I think i've seen it done.


    Selling DJ/Habbo layout, more info here.


  4. #4
    Join Date
    Mar 2007
    Posts
    129
    Tokens
    0

    Default

    Just make a script so you can select from a drop down which you want to edit then it inserts the values into input boxes or text areas and on submit you make a mysql_query to update the ID
    Making PHP Scripts for Paypal can code loads of things =)

    *I'll make it show you. You pay i send

    PM me =)

  5. #5
    Join Date
    Jul 2005
    Location
    Belgium
    Posts
    2,492
    Tokens
    147

    Latest Awards:

    Default

    PHP Code:
    $column "Hi";
    $update mysql_query("UPDATE dbname SET `columnname` = '$column'); 
    something like that, (more or less)

    edit=

    so if you have a page "edit.html'
    with

    <form action="update.php" method="POST">
    <input tye="text" name="column1" value="Hi" /><br />
    <input type="submit" name="update" value="Update the db" />
    </form>

    Then your update.php would be something like

    PHP Code:

    if($_POST["update"]){ //if update button is clicked
    $column $_POST["column1"]; //the field 'column1's stuff you entered
    $update mysql_query("UPDATE dbname SET `columnname` = '$column'); //update

    echo("
    Db updated!");

    }else{
    echo("
    you did not hit the submit button!");

    or something
    Last edited by [Oli]; 11-12-2007 at 10:45 AM.

  6. #6
    Join Date
    Oct 2007
    Location
    Luton, England
    Posts
    1,548
    Tokens
    388
    Habbo
    DeejayMachoo

    Latest Awards:

    Default

    PHP Code:

    if($_POST["update"]){ //if update button is clicked
    $column $_POST["column1"]; //the field 'column1's stuff you entered
    $update mysql_query("UPDATE dbname SET `columnname` = '$column'"); //update

    echo("Db updated");

    } else {
    echo(
    " <form method=\"POST\">
    <input tye=\"text\" name=\"column1\" value=\"Hi\" /><br />
    <input type=\"submit\" name=\"update\" value=\"Update the db\" />
    </form>"
    );

    ^^ easier?
    Last edited by DeejayMachoo$; 11-12-2007 at 11:42 AM.


  7. #7
    Join Date
    Jul 2005
    Location
    Belgium
    Posts
    2,492
    Tokens
    147

    Latest Awards:

    Default

    Quote Originally Posted by Oojamaflip View Post
    PHP Code:

    if($_POST["update"]){ //if update button is clicked
    $column $_POST["column1"]; //the field 'column1's stuff you entered
    $update mysql_query("UPDATE dbname SET `columnname` = '$column'"); //update

    echo("Db updated");

    } else {
    echo(
    " <form method=\"POST\">
    <input tye=\"text\" name=\"column1\" value=\"Hi\" /><br />
    <input type=\"submit\" name=\"update\" value=\"Update the db\" />
    </form>"
    );

    ^^ easier?
    Obviously :p
    Just thought he might not know php that well (& not know you have to backslash the "s in the form so I thought id do it with an html page )

  8. #8
    Join Date
    Apr 2007
    Location
    england
    Posts
    536
    Tokens
    0

    Default

    I want an edit option/link beside each comment, then if you click the link you'll be able to edit whatever commetn was there. Is that possible?

    So say I have ten comments, and the edit link beside each comment. Lets say I click the edit link beside comment #4, ai'll be taken to a form where I can edit comment #4.
    Last edited by adamFTW; 11-12-2007 at 01:17 PM.


    Selling DJ/Habbo layout, more info here.


  9. #9
    Join Date
    Jul 2005
    Location
    Belgium
    Posts
    2,492
    Tokens
    147

    Latest Awards:

    Default

    Quote Originally Posted by adamFTW View Post
    I want an edit option/link beside each comment, then if you click the link you'll be able to edit whatever commetn was there. Is that possible?

    So say I have ten comments, and the edit link beside each comment. Lets say I click the edit link beside comment #4, ai'll be taken to a form where I can edit comment #4.
    Yes it's possible (I have it on TemplateNation's auction comments/bids)
    But to be honest.
    Make sure you know php first, becouse if you don't you'll get stuck ;l

  10. #10
    Join Date
    May 2006
    Posts
    1,797
    Tokens
    0

    Latest Awards:

    Default

    Yea..

    On the edit comment button, make it link to comment.php?id=*comment id*

    In comment.php

    PHP Code:
    <?php
    function clean($str)
    {
    $str strip_tags(addslashes(stripslashes(htmlspecialchars($str))));
    $str mysql_real_escape_string($str);
    }
    $comment clean($_POST[comment]);
    $id clean($_GET[id]);
    if(isset(
    $comment) || !empty($comment))
    {
    mysql_query("update comments set comment = '$comment' where id = '$id'");
    echo(
    "This comment has been edited successfully!");
    echo(
    '<meta http-equiv="refresh" content="2;url=index.html" />');
    }
    else
    {
    ?>
    <form action="comment.php" method="post">
    <label for="comment">Edit Comment:</label>
    <textarea name="comment" cols="40" rows="6"><?php 
    $get_current 
    mysql_fetch_array(mysql_query("select comment from comments where id = '$id'"));
    echo(
    "$get_current[comment]");
    ?>
    </textarea>
    <br /><br />
    <input type="submit" value="Edit Comment!" />
    </form>
    <?php ?>
    Last edited by MrCraig; 11-12-2007 at 02:00 PM.
    Coming and going...
    Highers are getting the better of me

Page 1 of 2 12 LastLast

Posting Permissions

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