atticus Posted November 3, 2007 Share Posted November 3, 2007 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(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/75877-mysql-edit-form/ Share on other sites More sharing options...
nuxy Posted November 3, 2007 Share Posted November 3, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/75877-mysql-edit-form/#findComment-384080 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.