Recursive Database Delete
I have two tables in my database, one for the folders, where each folder has a parent id and an id itself, and one for the files where each file has a parent id for the folder its in. Now If the user deletes a folder, every file and folder within it, no matter how many there are, should be deleted. Can anyone give me the idea?
View Complete Forum Thread with Replies
Related Forum Messages:
Delete Files Recursive
I have a problem and don't know where to begin. My default folder is export. This is where all the files comes in, with all kinds of extentions, but with also a lot of sub-folders. I have a text file with all the extentions, I like to delete from the export folder and all the subfolders. 1 extention at 1 row. Some of these extentions are 'exotic' like exe--fileslack ,so not only the common 3 characters extentions. Is there a way to delete those not wanted files automaticly, without harming the other extentions.
View Replies !
Delete From Database
I have code that does not delete from a database. The same code (cut an paste in the same file, but different function and having a different query) works. So, of course, I tested the query interactively. I echoed the query and did a cut and paste when interactively connect to the database. That one worked so it isn't the query since interactively it is seeing exactly the same thing as the code produces. Here is the code: function deleteCatalog($catalog) { $query = "DELETE FROM CatalogNames WHERE sCatalogID='" . $catalog . "'"; mssql_select_db($database_Login, $_SESSION['Login']); $result = mssql_query($query, $Login); ... } The $query echos: DELETE FROM CatalogNames WHERE sCatalogID='CMP' As an example of code that works (in the same file) function addToCatalog($cat_id, $cat_name) { $query = "INSERT INTO CatalogNames (sCatalogID, sCatalogName) " . "VALUES ('" . $cat_id . "', '" . $cat_name . "')"; mssql_select_db($database_Login, $_SESSION['Login']); $result = mssql_query($query, $_SESSION['Login']); ... } The second and third lines are identical (cut and pasted) as in other places in the same code. In fact, it is only in this file that I do all the database work. Every other function works. This is the only delete, however.
View Replies !
Delete Database
using php and mysql how can i tell the my website to move any entry older than 30 days to a different table and then delete it below i have some script i did try but this doesnt work (im using unix timestamp incase that changes anything) mysql_query(" INSERT INTO newsarchive (id, postdate, title, newstext) SELECT id, postdate, title, newstext FROM news WHERE postdate < DATE_SUB(curdate(), INTERVAL 30 DAY)"); mysql_query("DELETE FROM news WHERE postdate < DATE_SUB(curdate(), INTERVAL 30 DAY)"); mysql_close($link); //clean up
View Replies !
Delete Item From Database
I still can't figure out how to delete an item from my shoppingcart. I have tried different ways to do this, but its impossible. -a button or link that deletes a item from my database -the php script that deletes it here is a suggestion: $slett = "DELETE ID, VARE, MODELL, STR, ANTALL, PRIS, TOTALPRIS FROM USER_TRACK WHERE USER_ID = "$user_id""; But how can i assign this to a button?
View Replies !
Delete Row In Database By A Selectbox?
I'm having a world of trouble with this. I have a selectbox of names....when they selectone and hit delete I want it to delete it from the database. I dont think i'm getting any value from the select box. Here is the code I have : PHP Code:
View Replies !
Delete A Row From A Database Table
I'm trying to delete a row from a database table. I've made a connection yet it's not working. Is there something wrong with the following code? mysql_query("DELETE * from `contactinfo` WHERE Submission_Number = 1 ");
View Replies !
How To Delete MySQL Database.
I've got three hostings with the GoDaddy hosting service. The hostings are supposed to provide only one MySQL database each. I've just recently noticed in the phpMyAdmin program that separate databases, each with the name "test," has appeared in two of the three hostings. I don't know how they got there. I didn't put them there. I contacted GoDaddy's technical support. They said that the "test" databases automatically comes with the phpMyAdmin program. Of course, that's not right. Anyway they said that I could delete the extra database without damaging anything.
View Replies !
Delete Data From Database
Let's say i have two tables, table_one; userid,userinput,indexno table_two; cond,qant,amp,indexno the indexno in table_one and table_two are the same.if i choose to delete one row of data in table_one,i want the data with the same indexno in table_two be deleted as well. how can i achieve this?
View Replies !
Database Auto Count What About Delete?
I have a table that give a unique ID to certain Articles. To give the ID i simply use the Auto count of the DB. But what happens when i delete a record? i am now missing an ID. How can i insert a row and give it the first available number? For example ID 1, 2, 4, 5, 6 i would Insert and set the ID number to 3.
View Replies !
Delete Data From MySQL Database
I am new to PHP and MySQL but I have setup a MySQL database. I can view the information in an HTML table using PHP scripts and can delete an entry form the database table, but what i need to do is to be able to delete an entry by selecting a radio button next to the relevent information however when i try to add a form in the PHP script i get an error.
View Replies !
Database Update/edit And Delete
i have spent the last few days trying to create a simple script to add/edit and delete entries in a mysql database with php. i have 1 database with 40 tables, each table has 3 fields (id, header and body) i created an input page with input fields for header and body. the table to store the information in is selected from a drop down menu. all this works fine. for some reason i cannot get the edit and delete page top work at all. would someone mind taking a look at the code and let me know what i am doing wrong? Code:
View Replies !
Delete From Flat File Database ?
I have recently started to code a Flat file database (just for fun) and it's going fine, but I was wondering whats the best way to delete a line from the file. I have this code below and I would like to add a delete button besides each line, which would obviously delete that line. But I do not know the best way to go around doing this as I don't know any specific functions to use. Code:
View Replies !
How To Delete All Database Entires Older Than 30 Days?
One of the fields in my database is called ad_date which is of date type and stored dates int he format YYYY-MM-DD. I would like to perform a DELETE SQL statement in my PHP script which deletes all records with an ad_date value older than 30 days. I knoy this is also an SQL question, but it is the 'older than 30 days' part which I'm stuck with and so figured it would be better in the PHP forum as I think I need to use PHP to calculate todays date - 30 days.
View Replies !
Simplify Insert-update-delete From Database
I'm looking for some functions or objects allowing to select-insert-update-delete from any table in a mysql database without the need to create a new query every time. Example: selectdatas(array('field1','field2','fieldn'),arra y('table1','tablen'),array('left join,idy','inner join, idx')) then the function build the query, execute it and then return an object with the query result. I must build a database driven site that is 90% of the time spent on building queries. If I may avoid build them manually it will help me a lot and let me gain some days of programming.
View Replies !
DELETE TimeOut Issue On A Large Database
When I run the script below, it results in a timeout. Running the commands through phpMyAdmin, results in a timeout too. Table1 has 40,000 records and Table2 has 35,000 records. I run the script to get rid of the duplicates. Is there a way that I can check for duplicates without the timeout issue? I tried the while loop through PHP and that results in a timeout too. Code:
View Replies !
Delete Database Base On User Choice
i want to let user delete their data from database. Note: one user may have more than one rows of data. table as following; TCid UserName Topic Content 1 q1 aa aa 2 q2 aa aa 3 q3 aa aa 4 q1 aa aa 5 q2 aa aa And i code as following steps; 1) ask user input user name 2) Display out all the data which the users got. (it is in delete.php file.) in here, i will use the check box, to let the user choices which data they will delete. note: i will try to make the Cid relate with the input name, so later on i can delete the data base on Cid. 3) i will delete the data base on the user choice(it is in deleteR.php file). but at the movement, i just want to test where i can get the value of the TCid or not (because i will delete some datas base on the TCid which the user choiced). The problem i go now, it is from the step 3, i could not get the TCid's value out, that's mean, i could not delete some data base on the user choiced. Code:
View Replies !
Delete Multiple Records In The Same Database Querie?
I have some code that deletes records from the database, in a loop. However its prety inificient as it makes a seperate database call in every loop whcih is slow. PHP Code: for ($i=0; $i<count($idarray); $i++) db_query("delete from clicks where id='$idarray[$i]'"); Is their a more efficient way of doing that? It is posible to delete multiple records in the same database querie?
View Replies !
Simple Login Page To Delete And Edit Things In Mysql Database
How do I build a simple login page on my site? I need a way to login to my admin area in my webshop, so I can add, delete and edit things in mysql database. I don't need help with add, delete and change things, only the login thing. The users should not even know that there is a admin login page. The users don't login to shop, they just shop so I can't use the user login page because there is no such page. Can someone please give me some guidelines for this?
View Replies !
Delete Record - When The Delete Link Is Clicked The Next Page Is Blank And Nothing Is Deleted.
This is my "delete.php" and this "todo/delete.php?id=64" an example of a link to it generated from the index.php page. When the delete link is clicked the next page is blank and nothing is deleted. What have I done wrong? <? include("dbinfo.inc.php"); mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $id="delete from todo where id='$id'"; mysql_query($id); mysql_close(); ?>
View Replies !
Mysql Delete - $query = Mysql_query("DELETE
how would i do the following ? $query = mysql_query("DELETE notes, datestamp, abs_value, ID FROM absence_mgt WHERE datestamp='$date' AND ID='$vtc_login' ") or die(mysql_error()); im just getting "Unknown table 'notes' in MULTI DELETE" ?
View Replies !
DELETE RECORDS - Database Adding New Records
iv got the database adding new records, and now I want it to display all of the records that are there buy name and id number, then i want u to be able to type in the id number of the customer u wish to delete and it shoudl delete it, sounds good buts its not actually deleting the record. it says it does, but its not doing it. Code:
View Replies !
Recursive PHP?
Do PHP support recursive calling, like this: function some_func ($some_arg) { $count = 0; // some code while (<some condition>) { if (<some condition>) { $count += some_func ($some_arg); } else { ++$count; } } return $count; }
View Replies !
Recursive Call
I'm having some problems with a recursive call. Basically I have a standard tree of nodes, and a function _calcSize() which takes a node as a parameter and returns the size of the node: PHP Code:
View Replies !
Recursive Function
i'm writing a tree menu which is database driven. basically i'd like to have it loop infinitely if needed. my table structure is simple for starting out: table: categories cid, category, parent i found a function that works perfectly in pulling the data recursively, however i had problems formatting the javascript for the tree menu correctly, so i ventured out on my own. however i've become stuck. the class is below, it's the last two functions which create the Javascript. denoted by "problem area" in the last if($branches) statement PHP Code:
View Replies !
Recursive Array
I have a category system in my product guide and the tables look like this: Table Categories - category_id - category_directory - is_product_category Table Categories_Xref - category_pid - category_id When I create a category it can go any level deep but I flag the final category (the product category) with the "is_product_category" field in the Categories table. An example looks like this: Systems -- Servers ---- PA-RISC ------ N Class Servers (is_product_category) -------- Product 1 -------- Product 2 -------- Product 3 Systems -- Servers ---- Intel ------ LH Series (is_product_category) -------- Product 1 -------- Product 2 -------- Product 3 Systems -- Workstations ---- PA-RISC ------ C Class Workstations (is_product_category) -------- Product 1 -------- Product 2 -------- Product 3 Now, when I am at the "Systems" level in the product guide I want to be able to find all the product categories that fall below below that category. In this case I should end up with the three above: N Class Servers, LH Series, C Class Workstations. When I click on the next category "Servers", my final product categories will be: N Class Servers, LH Series. This is what I came up with but unfortunately it only goes through one of the branches but not all. PHP Code:
View Replies !
Recursive - Like Variables
Say I want a variable to equal a part on an array til all the way to the end of the array or from the point i specify to the beginning.. Anybody know how to do this? $_this = $array[5] . (all the way down to array[0]); or $_this = $array[5] . (all the way to the end of the array, end($array);
View Replies !
Recursive Mkdir
I am using this sample script I got from php.net but it doesn't seem to be setting the permissions correctly. If I then go in and run a chmod on them I can make the change but I need it to be 0777 when the directory is created. What it is doing is first makes a folder named the job_id, then makes inside that folder a folder named the date. so when my form gets processed it runs the function: MakeDirectory($file_dir . $job_folder . $dir_date, 0777); PHP Code: function MakeDirectory($dir, $mode) { if (is_dir($dir) || @mkdir($dir,$mode)) return TRUE; if (!MakeDirectory(dirname($dir),$mode)) return FALSE; return @mkdir($dir,$mode); }
View Replies !
Recursive Script
I'm trying to make a forum with a recursive script showing the entire discussion thread, but I find it impossible. In my database table I have a messageParentId that shows if this is a new message thread (id=0) or an answer to an existing message (id=zzzzz). I have managed to make a script part that goes back or forth all the way in one level, but I don't know how to make a script that gives me all subsequent answers if a message has more than one answer.
View Replies !
Recursive Folder
A seemingly simple problem with(out) a seemingly impossible solution. PHP Code: function subfolders($folderIn = '', $levelIn = 0) { Â Â Â Â $folderName = $folderIn; Â Â Â Â $folderIn .= ($folderIn!='') ? '/' : '' Â Â Â Â $levelOut = $levelIn+1; Â Â Â Â $tmp = glob($folderIn.'*', GLOB_ONLYDIR); Â Â Â Â foreach($tmp as $key=>$value) { Â Â Â Â Â Â Â Â $dir[] = end(explode('/', $value)); Â Â Â Â Â Â Â Â $tab = 'Â Â Â Â ' Â Â Â Â Â Â Â Â $str = '' Â Â Â Â Â Â Â Â for($i=0; $i<$levelIn; $i++) { $str .= $tab; } Â Â Â Â Â Â Â Â echo $str.$dir[$key]." "; Â Â Â Â Â Â Â Â echo $str.'<font color="red">Â Â subfolders('.$dir[$key].', '.$levelOut.')</font>'." "; Â Â Â Â Â Â Â Â subfolders($dir[$key], $levelOut); Â Â Â Â }
View Replies !
Support Recursive
I assume the answer is yes. I try to write readSubdir function read all files in all sub-directories. <?php readSubdir("Documents/2005"); function readSubdir($dirPath) { $dirPointer = opendir($dirPath); while (($file = readdir($dirPointer)) != false) { if ($file == "." || $file == "..") continue; if (filetype($file) == "dir") { # if (is_dir($file) == true) { # if (strcmp(filetype($file), "dir") == 0) { readSubdir($file); } else { string(3) "dir" ..
View Replies !
Can't Get Head Around Recursive Function.
My question relates to a directory site I'm working on. I have an ID for a category. This is likely the child of child of a child, etc. category. For example - Holiday: Travel: Plains Given that the ID for plains is, say 10, I want to build the above with navigation, ie. looking like:
View Replies !
Possible Bug With Recursive Array References
I am using PHP 5.0.4 with Apache 2, on WinXP Pro. This behavior appears to be fundamental however, and should not be affected by platform. It would seem that there is some kind of bug in the process that creates the reference when it is being assigned to an array element within itself. If it is already referenced, it just assigns the existing reference and avoids the problem. As I was reading the documentation about references, I noticed the warning about "complex arrays". Here is what it says: ----- begin PHP docs ----- Complex arrays are sometimes rather copied than referenced. Thus following example will not work as expected. Example 21-3. References with complex arrays <?php $top = array( 'A' => array(), 'B' => array( 'B_b' => array(), ), ); $top['A']['parent'] = &$top; $top['B']['parent'] = &$top; $top['B']['B_b']['data'] = 'test' print_r($top['A']['parent']['B']['B_b']); // array() ?> ----- end PHP docs ----- So I decided to play around with this, and sure enough I got the same results. But after making a few changes, I discovered that the behavior is caused by recursively assigning the reference, and not due to the array structure itself. Consider this example code: <?php $top = array( 'X' => 1, 'Y' => 1, 'Z' => 0 ); $top['Y'] = &$top; $top['X'] = &$top; $top['Z'] = 4; echo "X = ", var_dump( $top['X']['Z'] ); echo "Y = ", var_dump( $top['Y']['Z'] ); echo "Z = ", var_dump( $top['Z'] ); ?> The results show: X = int(0) Y = int(4) Z = int(4) The result for X still has the original value. This would seem to agree with the orginal statement in the PHP docs. But, if you reverse the order of the reference assignments like this: $top['Y'] = &$top; $top['X'] = &$top; $top['Z'] = 4; Then, the result for Y has the original value. X = int(4) Y = int(0) Z = int(4) Furthermore, if you assign some arbitrary variable a reference to $top before doing anything else... $z = &$top; The output appears to be "correct" now: X = int(4) Y = int(4) Z = int(4) Looking at the var_dump of the actual resulting array struct reveals that where the reference is being assigned matches the contents of the array at *that point in time* up until the next recursive reference assignment. At that point $top branched off, leaving the first one pointing to the previous instance. So it would appear that it is actually a fractal array structure :) Each member that gets another ref to $top adds another fractal generation to the var_dump. But nonetheless, assigning a reference to a separate variable stops the branching for all subsequent recursive reference assignments. So it appears that assigning a reference to an element within itself like that does not correctly create the reference, unless the reference was already created. Another way to demonstrate this is to compare the output of these two scripts: <?php $top = array( 'W' => 1, 'X' => 1, 'Y' => 1, 'Z' => 0 ); $top['WW'] = 'wwwww' $top['W'] = &$top; unset ( $top['WW'] ); $top['XX'] = 'xxxxx' $top['X'] = &$top; unset ( $top['XX'] ); $top['YY'] = 'yyyyy' $top['Y'] = &$top; unset ( $top['YY'] ); $top['Z'] = 4; var_dump( $top ); ?> <?php $top_t = array( 'W' => 1, 'X' => 1, 'Y' => 1, 'Z' => 0 ); $top_t['WW'] = 'wwwww' $top_w = $top_t; $top_w['W'] = &$top_w; unset ( $top_w['WW'] ); $top_w['XX'] = 'xxxxx' $top_x = $top_w; $top_x['X'] = &$top_x; unset ( $top_x['XX'] ); $top_x['YY'] = 'yyyyy' $top_y = $top_x; $top_y['Y'] = &$top_y; unset ( $top_y['YY'] ); var_dump( $top_y ); ?> Basically, the output is the same, except that in the first one, the dump of $top['Y']['Y'] is shorted to "*RECURSION*" but not in the second. Now compare the output of these two scripts: <?php for ( $i = 0; $i < 10; $i ++ ) $top[$i] = &$top; $top['A'] = 'AAAAA' var_dump( $top ); ?> <?php $z = &$top; for ( $i = 0; $i < 10; $i ++ ) $top[$i] = &$top; $top['A'] = 'AAAAA' var_dump( $top ); ?> The only difference is the reference assignment at the beginning of the second one. But the results differ vastly. The first outputs over 157457 lines, while the second only outputs about 2554 lines. What I would like to know, is if this is actually a bug, or if this behavior is intentional. I do not have much knowledge of how the Zend Engine creates the references. But I find it at least somewhat dangerous that it can have that "fractal" effect so easily. And since it can be avoided by simply setting a reference to a separate variable, I am convinced that something is broken (or at least VERY confusing). The design of the language does not seem to justify this statement: "make a direct reference assignment to the array before adding recursive references inside it, or else the structure will branch with each assignment" So... any thoughts?
View Replies !
Recursive Category Display?
I'm trying to put together a file download system with categories / subcategories. I made the following 3 tables: Code: FILES ------------------------------------------ FILE_ID NUMBER FILE_NAME VARCHAR2 FILE_DESC VARCHAR2 FILE_DL_COUNT NUMBER FILE_CATEGORIES ------------------------------------------- CAT_ID NUMBER CAT_NAME VARCHAR2 CAT_DESC VARCHAR2 PARENT_ID NUMBER FILE_CATEGORIES_REL ------------------------------------------- FILE_ID NUMBER CAT_ID NUMBER I am using Oracle, so no worries about the non mysql data types. So I have been looking at freeware code for about 2 days and I can't understand how to create a function that recursively displays my categories. Ideally I am trying to output a table Such that when I click on a category, it displays sub categories and files within it.
View Replies !
Recursive Function Problems
I have got a number of functions that query my database and displays a particular catagory passed in the url. The functions display any sub category that category may have as well as well as teaser text. All of this is displayed dymanically in row of 3 column table layout. This is queried using a simple MySQL wrapper... and the query function in the wrapper uses mysql_connect() Now the portion of the site that uses this is not live so no one uses it but myself for testing etc. However I have been having a number of issues some related to some problems with my shared host. but I am wondering if my function are the cause of "Too many connections errors" while i am working on and testing. The functions are below skimmed with the necessary info. if someone can lend a fresh pair of eyes when they have got the time it's appreciated. The first uses the value passed in a url to get the category and category details. The second called from within the first uses the category id to query the db again and return all records(subsections) that belong to that query. and then does another query to see if those sub sections have subsections. PHP Code:
View Replies !
Recursive Directory Removal
I want to remove a directory and all of its contents recursively. Could be several files and directories within. Thought about reading the directory removing its contents, reading any directories within, removing their contents.... etc.
View Replies !
Recursive File Search
question about a recursive file search. I'd like to do a recursive search for jpg-files and add the filenames (full path) to a mysql database.
View Replies !
Pass Value From Recursive Function
Hello, I have a recursive function which is running as expected. However, I dont know how could I access the variable in the recursive function outside of the function scope. The variables are in array. Below is my code. Thanks! //get forwarder id $sql = "select * from forward_network where email='$email'"; $tab = mysql_query($sql) or die("Cannot select email"); $row = mysql_fetch_array($tab); $forwarder_id = $row['id']; //find children of forwarder $children = get_children($forwarder_id); print_r($children); function get_children($id) { $sql = "select * from forward_network where parent_id=$id"; $tab = mysql_query($sql) or die("Cannot get children"); if($tab) { //if there is value in $tab or children are found, then store it while($row = mysql_fetch_array($tab)) { $child['id'] = $row['id']; $child['email'] = $row['email']; $child['parent_id'] = $row['parent_id']; $child['level'] = $row['level']; //get children of children ,, recursive print "<pre>"; print_r($child); print "</pre>"; print "<br>"; get_children($row['id']); } } return $child; }
View Replies !
Convert Function To Be Recursive
I've got a function that reads all files and folders in a directory given directory. I would like this to be recursive, so when it encounters a folder, it runs the function over again with the new folder (directory). Problem is, I didn't write this function, so I'm not exactly sure how to accomplish this. Code:
View Replies !
Allinone/Recursive Script
I'm trying to create a combined login/database input script that has an if conditional where if the login details have been entered it present the database input screen and if they are not entered it presents the login screen. Now I've got it to work, it runs, but both forms are being displayed, and it seems to be ignoring the if conditional (obviously when the page first loads nothing's been entered). Code:
View Replies !
Recursive MySQL Query?
I'm try to create an unordered list of parent/child relationships in my DB. My DB table is setup like this. members -member_id -fname -lname -parrent_id So I want to query this table and output an unordered list like this: Code:
View Replies !
Copy Recursive Directories
I need to be able to do a recursive copy of a directory on a staging server (virtual) to a the production server (another virtual on the same machine.) I've been tring the examples at http://www.php.net/copy, after much tweaking, I still can not get this to work. I get no errors anywhere and when I check the paths they are correct. The permissions are correct as well. Code:
View Replies !
|