Styles2304 Posted August 15, 2007 Share Posted August 15, 2007 I have a section on my church website that pulls announcements stored in mySQL and displays them with PHP. I recently started working on a control panel so that other people could login and edit/create the announcements so as to keep it up to date and lighten my load. I use a while statement to display all of the bits of news but my question is how can I make an edit button specific to each row in the table on mysql? All I need to really be able to do is have an edit button spit out for each post that will set a session variable to that particular posts index number. I created the mysql table with this in mind and have index numbers to reference the chunks of data. Does anyone have an idea? Quote Link to comment https://forums.phpfreaks.com/topic/64973-solved-editing-posted-bulletins/ Share on other sites More sharing options...
Styles2304 Posted August 15, 2007 Author Share Posted August 15, 2007 while ($row = mysql_fetch_array($result)) { $entrydate = $row['EntryDate']; $data = $row['Data']; $indexno = $row['IndexNo']; $announcements .=<<<EOD <table with="100%" cellpading="0" cellspacing="0" border="0"> <tr> <td colspan="2"> <font class="h3"> $entrydate </font> </td> </tr> <tr> <td width="5"> </td> <td width=*> <font class="h3"> $data </font> </td> </tr> </table> <br><br> <form method="post" action="$indexno"> <input type="submit" name="submit" value="Edit"> Am I even on the right track? Quote Link to comment https://forums.phpfreaks.com/topic/64973-solved-editing-posted-bulletins/#findComment-324236 Share on other sites More sharing options...
Fadion Posted August 15, 2007 Share Posted August 15, 2007 If the basic idea of this is displaying records and showing an edit button to edit each record u may have: while($row = mysql_fetch_array($result)){ $indexNo = $row['indexNo']; echo "<a href=\"edit.php?indexNo=$id\">Edit</a>"; } Or in your specific case with the submit button: <form method="post" action="<?php echo "edit.php?id=$indexNo"; ?>"> <input type="submit" name="submit" value="Edit"> In each case the edit button/link will point to edit.php with a respectively post/get variable which contains the id of the selected row. Hope its what u were looking for. Quote Link to comment https://forums.phpfreaks.com/topic/64973-solved-editing-posted-bulletins/#findComment-324249 Share on other sites More sharing options...
Styles2304 Posted August 15, 2007 Author Share Posted August 15, 2007 I believe I understand that ok . . . I'll play around a little bit and post back! Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/64973-solved-editing-posted-bulletins/#findComment-324256 Share on other sites More sharing options...
Styles2304 Posted August 15, 2007 Author Share Posted August 15, 2007 I'm still missing something . . . since I'm using the EOD deal, I don't need to echo the link so I did this: <a href="edit.php?IndexNo=$IndexNo">Edit</a> Just to test to make sure $IndexNo was actually a value, I have it spit it out right next to the edit button and it works fine. On the edit page . . . wouldn't I retrieve that variable with: <?php echo $_POST['IndexNo']; ?> That doesn't spit anything out . . . am I missing something simple? Quote Link to comment https://forums.phpfreaks.com/topic/64973-solved-editing-posted-bulletins/#findComment-324281 Share on other sites More sharing options...
Styles2304 Posted August 15, 2007 Author Share Posted August 15, 2007 Ah wait a sec, I just happen to think . . . would the fact that I'm doing this in a frame mess anything up? Quote Link to comment https://forums.phpfreaks.com/topic/64973-solved-editing-posted-bulletins/#findComment-324282 Share on other sites More sharing options...
Styles2304 Posted August 15, 2007 Author Share Posted August 15, 2007 bump Quote Link to comment https://forums.phpfreaks.com/topic/64973-solved-editing-posted-bulletins/#findComment-324466 Share on other sites More sharing options...
Styles2304 Posted August 15, 2007 Author Share Posted August 15, 2007 lol nevermind . . . that's a stupid question. Quote Link to comment https://forums.phpfreaks.com/topic/64973-solved-editing-posted-bulletins/#findComment-324472 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.