/    Sign up×
Community /Pin to ProfileBookmark

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?

[code=php]<?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’;

?>[/code]

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@The_Little_GuyMar 29.2007 — Something like this:
[code=php]
<?php
$sql = mysql_query("SELECT * FROM databse_name WHERE id={$_GET['id']}");
$row = mysql_fetch_array($sql);
echo'
<table border="1" cellpadding="3" cellspacing="1">
<tr valign="top">
<td>First Name</td><td><input type="text" name="fname" value="'.$row['fname'].'" /></td>
<td>Last Name</td><td><input type="text" name="lname" value="'.$row['lname'].'" /></td>
<td>Username</td><td><input type="text" name="username" value="'.$row['username'].'" /></td>
<td>Password</td><td><input type="password" name="password" value="'.$row['password'].'" /></td>
</tr>
</table>
';
?>
[/code]
×

Success!

Help @tomyknoker spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.12,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...