Jump to content

Edit Mysql Data With Forms


Recommended Posts

I was wondering if someone could point me in the right direction to a tutorial or something along those lines. Basically I want to be able to pull data from a mysql db into a form and edit the information in that form and then send the updated data back to the db. Got any links? :)

Link to comment
Share on other sites

Maybe this'll get you started:


$username = "username";
$password = "password";
$database = "database";
$table = "table";

// Connecting, selecting database
$link = mysql_connect("localhost", "$username", "$password")
  or die('Could not connect: ' . mysql_error());
echo 'Connected successfully';
mysql_select_db("$database") or die('Could not select database');

// Performing SQL query
$query = "SELECT * FROM $table";
$result = mysql_query($query) or die('Query failed: ' . mysql_error());

// Printing results in HTML
// echo "<table>\n";
echo "<html><body>";
echo "<p>";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
  foreach($line as $key => $value) {
   echo "\$$key == $value";
   echo "<br>";
  echo "<p>";

echo "</body></html>";

// Free resultset

// Closing connection


When I have more time, if you still haven't figured the rest out, I might be able to look deeper into it.

Although, you could just use phpmyAdmin in your controlpanel:


Edited by Steve Scrimpshire
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...