ecabrera Posted November 24, 2011 Share Posted November 24, 2011 ok i want admin to click on the edit button and a form shows up where you can edit your events and stuff like that but i cant get the edit button to work <?php require 'scripts/connect.php'; echo " <table width='472' border='0'> <tr> <th width='43' height='21' scope='col'>Event Id</th> <th width='116' scope='col'>Event Nane</th> <th width='106' scope='col'>Event Type</th> <th width='63' scope='col'>EDIT</th> <th width='63' scope='col'>DELETE</th> </tr> </table>"; $sqlCommand = "SELECT * FROM events"; $out = mysql_query($sqlCommand); while ($row = mysql_fetch_assoc($out)){ $eventid = $row["id"]; $eventname = $row["eventname"]; $eventtype = $row["typeevent"]; $eventinfo = $row["eventinfo"]; $date = $row["date"]; $time = $row["time"]; $livetickets = $row["sale"]; $numtickets = $row["numtickets"]; $pricestudents = $row["studentsprice"]; $priceseniors = $row["seniorsprice"]; $priceadults = $row["adultsprice"]; if ($_POST['editbtn']){ echo "<form action='editevent' method='post'> <table> <tr> <td>Event Name</td> <td></td> <tr> <tr> <td></td> <td></td> <tr> <tr> <td></td> <td></td> <tr> </table> </form> "; }else echo" <table width='472' border='0'> <tr><form action='editevent.php' method='post'> <th width='59' height='21' scope='col'>$eventid</th> <th width='159' scope='col'>$eventname</th> <th width='151' scope='col'>$eventtype</th> <th width='85' scope='col'><input type='button' name='editbtn' value='Edit' /></th> <th width='85' scope='col'><input type='button' name='deletebtn' value='Delete' /></th> </form></tr> </table>"; } ?> Link to comment https://forums.phpfreaks.com/topic/251750-edit-button/ Share on other sites More sharing options...
sunfighter Posted November 25, 2011 Share Posted November 25, 2011 To get a button to preform an action you need to tell it to do so and the JAVASCRIPT that it is to activate. <input type='button' name='editbtn' value='Edit' /> S/B <input type='button' name='editbtn' value='Edit' onclick=\"call java function\" /> And you need to write that function. Link to comment https://forums.phpfreaks.com/topic/251750-edit-button/#findComment-1291178 Share on other sites More sharing options...
peppericious Posted November 25, 2011 Share Posted November 25, 2011 To get my 'Edit' links to take me to an 'edit_news_item.php' page, I query the database to retrieve an array of info about the particular news item, including its id. Then, I do this: echo "<p><a href='edit_news_item.php?news_id=" . $row['news_id'] . "'>Edit</a></p>"; That way, the id of the news entry is passed in the URL to the edit_news_item.php page (where another query can pull up whatever data I want to edit in the news entry). I'm not an expert, but the above works for me. Link to comment https://forums.phpfreaks.com/topic/251750-edit-button/#findComment-1291194 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.