Schlo_50 Posted April 27, 2007 Share Posted April 27, 2007 Hello, i am trying to make my own calendar system. I have a mySQL database with the rows month and description stored in it. On the calender page i have a drop down menu to select the month and text area box for the description of the event. I can at the moment add events to my database but now want to add the php to delete all news for a specific month using a drop down menu. I have some code to do this in the script but it needs finishing. If someone could help revise the whole script so it woulds nicely it would be very much appreciated! <!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>Untitled Document</title> <link href="rotary.css" rel="stylesheet" type="text/css" /> <style type="text/css"> <!-- body { background-color: #6191c2; } --> </style></head> <body> <blockquote><blockquote><blockquote> <div align="center" class="rotary"><u>Calendar</u> -Calendar </div> <p align="center" class="rotary"> <p align="center" class="rotary"><a href="editcal.php">Refresh for Preview</a> <center><table width="251" border="1"> <tr> <td width="241"> <div align="center"> <?php include "calendarcontent.php"; ?> </div></td> </tr> </table></center> <p align="center" class="rotary"> <?php $self=$_SERVER['PHP_SELF']; $month=$_POST['month']; $event=$_POST['message']; ?> <?php $conn = mysql_connect( "host","user","pass" ) or die( "Error connecting to database!" ); $dbsel = mysql_select_db( "rotaryclub" ) or die( "Error connecting to Database!" ); $sql = "INSERT INTO calendar ( month, message ) VALUES ( '$month','$event' )"; $rd = mysql_query( $sql, $conn ); ?> <center> <form id="form1" name="form1" method="post" action=""> <label><span class="rotary">Select Month</span> <select name="month" id="month"> <option>January</option> <option>February</option> <option>March</option> <option>April</option> <option>May</option> <option>June</option> <option>July</option> <option>August</option> <option>September</option> <option>October</option> <option>November</option> <option>December</option> </select> </label> <p class="rotary"> </p> <p class="rotary"> <label>Enter Event <textarea name="message" rows="5"></textarea> </label> <input type="submit" name="Submit12" value="Submit" /> </p> </form> <?php if(isset($_GET['action']){ $action = $_GET[action]; } if(isset($_GET['action']){ $month= $_GET['month']; }else{ $month = bad; } if($action == "delete"){ if(is_numeric($month){ // delete sql query goes here }else{ echo "No month supplied!"; } // redirect here, you dont want users to stay on the same page when you pass URL vars that affect the database } <p class="rotary">Delete news for month selected </p> <p class="rotary"> ?> <label> <input type="submit" name="Submit" value="Delete" /> </label> </p> </center> <p align="center" class="rotary"> </p> </body> </html> Link to comment https://forums.phpfreaks.com/topic/48892-revision-of-code-needed/ Share on other sites More sharing options...
Schlo_50 Posted April 27, 2007 Author Share Posted April 27, 2007 BUMP Link to comment https://forums.phpfreaks.com/topic/48892-revision-of-code-needed/#findComment-239749 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.