Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Mar 2006
    Posts
    459
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Edit MySQL Column & Update

    Hi all,

    I am able to display the data from a table in my database. I have an Edit link, which you can see in the code. Obviously it's not active but want to when it is pressed to display the current user's data in textfield's that I can change and then click Update and it saves them... Anyone have any ideas?

    PHP Code:
    <?php

    /* connect to the mysql database and use different queries for the count of members */

    include 'configure.php';
    include 
    'open.php';

    //navigation
    include("nav.php");

    $info mysql_query("SELECT * FROM tbladministrators");

    echo 
    '<table border="1" cellpadding="3" cellspacing="1">
      <tr valign="top">
        <td>First Name</td>
        <td>Last Name</td>
        <td>Username</td>
        <td>Password</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>'
    ;
        
    if (
    mysql_num_rows($info) < 1) {
    echo 
    '<tr valign="top">
      <td colspan="4">There are no members that match the query. Please go back and try again</td>
        </tr>'
    ;
    }

    else {
       while (
    $qry mysql_fetch_array($info)) {

    //create the layout
    ?>
    <link href="cs_style.css" rel="stylesheet" type="text/css" />

      <tr valign="top">
        <td><?php echo $qry['firstname']; ?></td>
        <td><?php echo $qry['lastname']; ?></td>
        <td><?php echo $qry['username']; ?></td>
        <td><?php echo $qry['password']; ?></td>
        <td>Edit</td>
        <td>Delete</td>
      </tr>
    <?php
       
    }
    }

    echo 
    '</table>';

    include 
    'library/closedb.php';

    ?>

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    You can create a new PHP page to do the editing, or you can put the edit form in a <div> that is initially hidden (CSS is "display: none"), and use Javascript to "unhide" the <div> when edit is clicked. This doesn't degrade gracefully though (meaning, Javascript must be enabled for it to work). I guess you could re-load the page and send a variable over to force the <div> to be shown all via PHP, rather than Javascript....

    There are lots of ways to achieve your goal, best thing is to do lots of research and see what you can come up with.


  •  

    Posting Permissions

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