Jump to content

mysql edit form?


atticus

Recommended Posts

Any suggesstions on adding an edit form to each result?

 

<?php
$sql = "SELECT * FROM upload2 ORDER BY `sort`";
$query = mysql_query($sql);
while($row = mysql_fetch_array($query)) {
echo "<div class=display>";
echo "<label>Title:</label>".$row['title']."<br />";
echo "<label>Description:</label>".$row['description']."<br />";
echo "<label>Image:</label><img src=".$row['path']."><br />";
echo "<label>Buy Link:</label>".$row['buy']."<br />";
echo "<label>Sort Order:</label>".$row['sort']."<br />";
echo "</div>";
}
mysql_close();
?>

 

 

Link to comment
https://forums.phpfreaks.com/topic/75877-mysql-edit-form/
Share on other sites

If you mean an HTML form, then yo could try this.

 

<?php
$sql = "SELECT * FROM upload2 ORDER BY `sort`";
$query = mysql_query($sql);
while($row = mysql_fetch_array($query)) {
echo "<div class=display>";
echo "<form action=" . $_SERVER['PHP_SELF'] . " method=post>";
echo "<label>Title:</label><input type=text name=title value=".$row['title']."><br />";
echo "<label>Description:</label><input type=text name=description value=".$row['description']."><br />";
echo "<label>Image Location:</label><input type=text name=location value=".$row['path']."><br />";
echo "<label>Buy Link:</label><input type=text name=buy value=".$row['buy']."><br />";
echo "<label>Sort Order:</label><input type=text name=buy value=".$row['sort']."><br />";
echo "</form>";
echo "</div>";
}
mysql_close();
?>

 

Then you will need a if statement to validate and update the entry in the database.

If you have any sort of id assigned in the row, then you could make it easier to update the current entries.

Link to comment
https://forums.phpfreaks.com/topic/75877-mysql-edit-form/#findComment-384080
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.