jetpacmidge Posted November 17, 2006 Share Posted November 17, 2006 Hi,I am using PHP v5, Apache v1.3 and MYSQL v5. I am unable to delete divisions from the table after selecting the age group that relates to the division.[code]<?php /* Program: DeleteDivision.php * Desc: A confirmation screen * is sent to the user. */ /* $age = $_POST['age']; */ $interest = mysql_escape_string($_POST['age']); /* $age = $_POST['division']; */ if (!empty($_POST['age'])) { $interest = $_POST['age']; } ?><html><head><title>Delete Division</title></head><BODY BGCOLOR="FAFAD2" TEXT="00008B" LINK="00008B" VLINK="00008B" ALINK="00008B"><?php include("connection.inc"); $connection = mysql_connect($host,$user,$password) or die ("couldn't connect to server"); $db = mysql_select_db($database,$connection) or die ("Couldn't select database"); /* echo */ /* $query = "DELETE FROM agegroup WHERE age='$division' "; */ /* $query = "DELETE FROM division WHERE age='$ageList' "; */ /* $query = "DELETE FROM division WHERE division='".$_POST['division']."' "; */ $query = "DELETE FROM division WHERE division='".$_POST['division']."' AND age='".mysql_escape_string($_POST['age'])."' "; $result = mysql_query($query) or die('Query failed: ' . mysql_error()); include("deletedivision_form.inc"); echo "<div align='center'> <a href='selectage.php'><font size=+1>Delete Another Division ?</a> <a href='tadburnfc.htm'>Return To Main Page</a></font></div>";?></body></html>[/code][code]<?php /* Program: ShowDivisions.php * Desc: Displays all the divisions in the age group. Category is passed * in a variable from a form. The information for each division * is displayed on a single line. */?><html><head><title>Show Divisions</title></head><body topmargin="0" marginheight="0"><?php include("connection.inc"); $connection = mysql_connect($host,$user,$password) or die ("couldn't connect to server"); $db = mysql_select_db($database,$connection) or die ("Couldn't select database"); /* $interest = $_POST['interest']; */ $interest = mysql_escape_string($_POST['age']); /* Select division from age group selected */echo $query = "SELECT division FROM division WHERE season='2006/07' and age='$interest'"; // 25 $result = mysql_query($query) or die ("Couldn't execute query."); ?> <div style='margin-left: .5in'><p align="left"> <b><font face="Arial, Helvetica, sans-serif" size="+2" color="#0000FF">Divisions</font></b> </p> <font face="Arial, Helvetica, sans-serif" size="+1" color="#0000FF"> <p> <p><b>Below is a list of divisions that are currently in the database.</b> <p>Select as many divisions that you want to delete from age group selected: </font><?php /* create form containing checkboxes */ echo "<form action='deletedivision2.php' method='post'>\n"; ?> <table width="25%"> <tr> <th align="left">Division</th> <th align="left">Delete</th> </tr> <?php while ($row = mysql_fetch_array($result)) { extract($row); echo "<tr>\n"; echo "<td>$division</td>\n"; echo "<td><input type='checkbox' name='division' value='$division'></td>\n"; echo "</tr>\n"; echo "<br>\n"; } ?> </table> <?php echo "<p><input type='submit' value='Delete Division'> </form>\n";?></body></html>[/code][code]<?php /* Program: deletedivision_form.inc * Desc: Displays form to delete the division from the database */?><html><head><title>Confirmation form for Deletion of Division</title></head><BODY BGCOLOR="FAFAD2" TEXT="00008B" LINK="00008B" VLINK="00008B" ALINK="00008B"><center> <b><font face="Arial, Helvetica, sans-serif" size="+4" color="#0000FF">Confirmation</font></b> </center><br><br><font face="Arial, Helvetica, sans-serif" size="+2" color="#0000FF"><?php echo "The following division has been deleted from the Tadburn FC Database: \n"?><br><br><br><br><table border="0" width="75%"><tr><th align="center">Season</th><th align="center">Age Group</th><th align="center">Division</th></tr><tr><td align="center"><?php echo $_POST['season'] ?></td> <td align="center"><?php echo $_POST['age'] ?></td>/* <td align="center"><?php echo $_POST['division'] ?></td> */<td align="center"><?php echo name="division[]" ?></td> </tr></table><br><br><br></font></body></html>[/code]Thanks :) Link to comment https://forums.phpfreaks.com/topic/27590-unable-to-delete-search-criteria-from-selecting-data/ Share on other sites More sharing options...
Psycho Posted November 17, 2006 Share Posted November 17, 2006 What errors are you getting? Link to comment https://forums.phpfreaks.com/topic/27590-unable-to-delete-search-criteria-from-selecting-data/#findComment-126160 Share on other sites More sharing options...
esukf Posted November 17, 2006 Share Posted November 17, 2006 On DeleteDivision.php echo the $query to see what you get.Are there more than one checkbox in your form in ShowDivisions.php? If so you need to indicate them as array in the html[code]echo "<td><input type='checkbox' name='division[]' value='$division'></td>\n"; [/code]and then loop through the array in DeleteDivision.php to get the checkbox values.Also in deletedivision_form.inc, the following line will product an error.[code]<td align="center"><?php echo name="division[]" ?></td>[/code] Link to comment https://forums.phpfreaks.com/topic/27590-unable-to-delete-search-criteria-from-selecting-data/#findComment-126167 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.