sw0o0sh Posted November 28, 2006 Share Posted November 28, 2006 Hi, I'm working on my content management system and have run into a complication. I don't know the proper function to fix my problem, so I'll attempt here.I'll comment throughout my code so you know what I am talking about, Please help.[code]<?php if($_POST[movefiles]){ // When the previous form is submit, this script runs $x=0; echo "<form method='post'><table cellspacing='2' cellpadding='2' border='1' bordercolor='#eeeeee' width='300' align='center'>"; echo "<tr><td align='center'>The following file(s) will be moved:</td></tr>"; while($x<$_POST[totalquerys]){ // runs the script as many times there is files to be moved if($_POST[$x] == NULL){echo"";}else{ // blocks out blank numbers echo "<tr><td><input type='hidden' name='move".$x."' value='$_POST[$x]' />• ".$_POST[$x]."</td></tr>"; } $x++; } echo "<tr><td align='center'>Select a desination folder:</td></tr>"; echo "<tr><td align='center'> <select name='destination'><option value='root' />/root</option>"; $dir = "directory/".$logged[webpage]."/"; if(is_dir($dir)){ if($dh = opendir($dir)){ while(($file = readdir($dh)) !== false) { if($file=='.' OR $file=='..') { echo ""; }else{ $type=filetype($dir."/".$file); if($type=='dir') { echo " <option value='/$file'>* $file</option> "; $subdir='directory/'.$logged[webpage].'/'.$file.'/'; // USING THE directory required from the first part of this script, i use the path to automatically generate another directory, as you can see, i would like to run this for as many directories there is, and so it keeps chaining. and so it keeps display sub directories.../*so say user1 has the directories:direct1/sub1/subsub3/subsub4/direct2/sub2/sub3/direct3/sub3/direct4the output of the selection is<option value=''>Direct1</option>.. etc .. <option value=''>--- SubSub3<option value='direct1/sub1/subsub3/subsub4/'>- - - - Sub sub 4</option>*/ if($hh = opendir($subdir)){ while(($subs = readdir($hh)) !== false) { $types=filetype($subdir.$subs); if($types=='dir'){ if($subs == '.' OR $subs == '..'){}else{ echo "<option value='/$file/$subs'>-- $subs</option>"; } } } } } } } closedir($dh); } } echo"</select>"; echo "</td></tr>"; echo "<tr><td align='center'>"; echo "<input type='hidden' name='totalrepeat' value='$x' />"; echo "<input type='submit' name='movenext' value='Move Files' />"; echo "</td></tr></table>"; echo "</form>"; }?>[/code]Please read the commentaries in the coding to see if you get what im trying to do. If its too hard thats alright, thanks anyway. Link to comment https://forums.phpfreaks.com/topic/28791-a-looping-loop-inside-of-a-loop/ Share on other sites More sharing options...
doni49 Posted November 28, 2006 Share Posted November 28, 2006 Do a search for "recursive" and/or recursion. Link to comment https://forums.phpfreaks.com/topic/28791-a-looping-loop-inside-of-a-loop/#findComment-131832 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.