I made a nice flowchart for you since this is kind of complicated.
Basically, I want to have a list of fields from a column in the database, displayed in a table. They have an EDIT button ext to them, and when you click the edit button you can edit the field. Then you click submit and it alters the table with the new value.
I pretty much know how to do each of the individual things, but I am having trouble combining all these things into one.
Flowchart:
Code:
STEP 1:
<table>
<th>First Name</th>
<?php
// Collects data from "users" table
$data = mysql_query("SELECT * FROM users")
or die(mysql_error());
// array
$info = mysql_fetch_array( $data );
// print data
// Print out the contents of the entry
Print "<tr><td>";
Print "".$info['fname'] . " ";
Print "</td><td>";
Print "".$info['lname'] . " ";
Print "</td><td>";
Print "".$info['email'] . " <br>";
Print "</td></tr>";
// loop for each row in the column
while($info = mysql_fetch_array( $data ))
{
Print "".$info['fname'] . " ";
Print "</td><td>";
Print "".$info['lname'] . " ";
Print "</td><td>";
Print "".$info['email'] . " <br>";
Print "</td></tr>";
}
?>
</table>
STEPS 2 & 3: (incomplete or possibly inaccurate as well)
<?php
if(isset($_POST['submit'])){
$variable = "somethinghere";
$variable = "somethinghere";
$variable = "somethinghere";
$variable = "somethinghere";
$variable = "somethinghere";
$query = "UPDATE users
SET fname='$variable1'
WHERE $variable2='$variable3' AND $variable4='$variable5'
(fname, lname, email) VALUES ('".$_POST['fname']."', '".$_POST['lname']."', '".$_POST['email']."')";
mysql_query($query);
}else{
?>
<div class="content">
<form method="post">
<div><strong>First Name:</strong><span class="errortext">*</span></div>
<div><input name="fname" type="text" /></div>
<div><strong>Last Name:</strong><span class="errortext">*</span></div>
<div><input name="lname" type="text" /></div>
<div><strong>Email:</strong><span class="errortext">*</span></div>
<div><input name="email" type="text" /></div>
<div><input id="submit-button" value="submit" name="submit" type="submit" /></div>
</form>
<?php }?>
</div>
Using JQuery is the way to change it.
Here’s a plugin: http://www.appelsiini.net/projects/jeditable/default.html ; http://www.appelsiini.net/projects/jeditable