Ult1matek1ll Posted February 16, 2012 Share Posted February 16, 2012 I'm trying to set it so that it will delete an entire populated directory based upon a value in the database then after finishing that to go back and delete that row in the database. my current code is <?php $page_title = "Central Valley LLC | Photo Addition" ?> <?php include("header.php"); ?> <?php include("nav.html"); ?> <div id="content"> <form action="delprod.php" method="post" enctype="multipart/form-data"> <label for="which">Choose A Product To Remove:</label> <?php $con = mysql_connect("localhost","phoenixi_cv","centraladmin"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("phoenixi_cvproducts", $con); $result = mysql_query("SELECT * FROM Products"); echo "<select name=\"which\">"; while($row = mysql_fetch_array($result)) { echo "<option "; echo "value=\"" . $row['id'] . "\">"; echo $row['Name'] . "</option>"; } echo "</select>"; mysql_close($con); ?> <br /> <input type="submit" name="submit" value="Submit" /> </form> </div><!--#content--> <?php include("footer.html") ?> and the delete script <?php $con = mysql_connect("localhost","phoenixi_cv","centraladmin"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("phoenixi_cvproducts", $con); $result = mysql_query("SELECT id FROM Products WHERE id=$_POST['which']"); $row = mysql_fetch_array($result) chdir('assets'); chdir('images'); $mydir = $row . '/'; $d = dir($mydir); while($entry = $d->read()) { if($entry!="." && $entry!="..") { unlink($_POST['which'] . '/' . $entry); } } rmdir($mydir); $result = mysql_query("DELETE * FROM Producs WHERE id=$_POST['which']"); ?> Thank you in advance for all your help. any easier ways of approaching this will be welcome as well Link to comment https://forums.phpfreaks.com/topic/257140-php-directory-delete-and-mysql-row-delete-help-please/ Share on other sites More sharing options...
Muddy_Funster Posted February 17, 2012 Share Posted February 17, 2012 I see the code. I see the delete script. I don't see where you tell us what the problem actualy is. Link to comment https://forums.phpfreaks.com/topic/257140-php-directory-delete-and-mysql-row-delete-help-please/#findComment-1318309 Share on other sites More sharing options...
Ult1matek1ll Posted February 19, 2012 Author Share Posted February 19, 2012 Thanks but the problem was resolved on the sql forum. $result = mysql_query("DELETE * FROM Products WHERE id=$_POST['which']"); there was the error so im solved XD Link to comment https://forums.phpfreaks.com/topic/257140-php-directory-delete-and-mysql-row-delete-help-please/#findComment-1318949 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.