Porkie Posted September 2, 2009 Share Posted September 2, 2009 Hey, As you can see in my code, i have a section whicxh loads the latest feeds from my database. However if i click edit to the side of one of my feeds i want it to load that feed into my table to allow me to edit my data. How do i do this? can someone please explain? Regards <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>RSS Feed </title> <style type="text/css"> <!-- .style1 { font-family: Arial, Helvetica, sans-serif; font-size: 14px; margin: 0px 0px 0px 0px; } .style2 { font-family: Arial, Helvetica, sans-serif; font-size: 18px; font-weight: bold; color: #CC00CC; margin: 0px 0px 0px 0px; } #feed_table { font-family: Arial, Helvetica, sans-serif; color: #FFFF00; position: absolute; margin: 100px 0px 0px 600px; } .style_search { font-family: Arial, Helvetica, sans-serif; font-size: 20px; margin: 0px 0px 0px 600px; } --> </style> </head> <?php require('core.inc.php'); echo page_header('Register'); echo $error; ?> <?php $con = mysql_connect(""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("", $con); $q ="SELECT * FROM ORDER BY date DESC "; $sql5 = mysql_query($q); echo '<table id="feed_table" width="400" border="1">'; echo '<tr><td>TOP 5 FEEDS</td><td colspan="2"><a href="rss_show.php">View All</td></tr>'; while ($row = mysql_fetch_assoc($sql5)) { echo '<tr>'; echo '<td>'; echo '<img style="width:16px;height:16px;" src="img/rss_image.jpg"/> '.$row['title']; echo '</td>'; echo '<td>'; echo '<a href="rss_edit.php">Edit </a>'; echo '</td>'; echo '<td>'; echo '<a href="rss_delete.php">Delete </a>'; echo '</td>'; echo '</tr>'; } echo '</table>'; echo '</P>'; ?> <form method="post" enctype="multipart/form-data"> <br /> <form id="addfeed" name="addfeed" method="post" action="rss_edit.php"> <table width="400" border="1"> <tr> <th width="105" scope="col" align="left">RSS Feed </th> <th width="198" scope="col"> </th> </tr> <tr> <td width="150pt">Title : </td> <td><label> <input name="rsstitle" type="text" id="rsstitle" size="33" /> </label></td> </tr> <tr> <td width="150pt">Link : </td> <td><label> <input name="rsslink" type="text" id="rsslink" size="33" value="http://" /> </label></td> </tr> <tr> <td width="150pt">Description : </td> <td> <label> <textarea name="rssdescription" cols="30" rows="5" id="rssdescription"></textarea> </label> </td> </tr> <tr> <td width="150pt">Author : </td> <td><label> <input name="rssauthor" type="text" id="rssauthor" size="33" /> </label></td> </tr> <tr> <td width="150pt">Date : </td> <td><label> <select name="doby"><?php for ($c = 1900; $c <= 2009; ++$c) { echo '<option value="'.$c.'">'.$c.'</option>'; } ?></select> <select name="dobm"><?php for ($c = 1; $c <= 12; ++$c) { echo '<option value="'.$c.'">'.$c.'</option>'; } ?></select> <select name="dobd"><?php for ($c = 1; $c <= 31; ++$c) { echo '<option value="'.$c.'">'.$c.'</option>'; } ?></select> </label></td> </tr> <tr> <td width="150pt">Image Upload :</td> <td><input type="file" name="avatar" /></td> </tr> <tr> <td width="150pt">Category :</td> <td> <select name="type"> <option value="ALL">ALL</option> <option value="Unsigned Music">Unsigned Music</option> <option value="Song Writing">Song Writing</option> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td><label> <input type="submit" name="Submit" value="Submit" /> <input type="reset" name="Reset" value="Reset" /> </label></td> </tr> </table> </form> <?php echo page_footer(); ?> Link to comment https://forums.phpfreaks.com/topic/172878-updating-data-in-databse/ Share on other sites More sharing options...
tommyda Posted September 2, 2009 Share Posted September 2, 2009 It would be much easier if you didnt hide your table names. <?php //Check if the form was submitted if yes update the database if (isset($_POST['save'])) { //GET Feed ID ED: yoursite.com/editfeed.php?ID=33 $feed_id = $_GET['ID']; mysql_query("UPDATE feeds SET content='$_POST[content]' WHERE id = '$feed_id'")or die(mysql_error()); echo 'Saved'; }; //Get feed from database $getfeed = mysql_query("SELECT * FROM feeds WHERE id = '$feed_id'")or die(mysql_error()); $feed = mysql_fetch_array($getfeed); //Display it in the edit feed form <form method="post"> <input type="text" name="content" value="<?php echo $feed['content'];?>"/> <input type="submit" name="save" value="save"/> </form> That should work Link to comment https://forums.phpfreaks.com/topic/172878-updating-data-in-databse/#findComment-911190 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.