davids_media Posted May 11, 2012 Share Posted May 11, 2012 I have created a table called directories. Now basically I have two fields; dirID (INT) directory (VARCHAR) now I am fully aware this might sound like more of an SQL question but I have three physical directories: db/images/web1 db/images/web2 db/images/web3 I have inputted them into the database but I was just wondering, how could I created a page which links those records to a directory. I want to have each row hyperlinked, with the output page displaying list of contents for each directory. How can I possibly achieve this please? Quote Link to comment https://forums.phpfreaks.com/topic/262422-field-type-for-file-directories/ Share on other sites More sharing options...
The Letter E Posted May 13, 2012 Share Posted May 13, 2012 I have created a table called directories. Now basically I have two fields; dirID (INT) directory (VARCHAR) now I am fully aware this might sound like more of an SQL question but I have three physical directories: db/images/web1 db/images/web2 db/images/web3 I have inputted them into the database but I was just wondering, how could I created a page which links those records to a directory. I want to have each row hyperlinked, with the output page displaying list of contents for each directory. How can I possibly achieve this please? You first need to return your rows from the db, then create a link that will pass the directory path to a php script. Creating the Link: <html> <body> <a href="/directory.php?dir=<?=$row[1]?>">LINK TO DIR 1</a> <a href="/directory.php?dir=<?=$row[2]?>">LINK TO DIR 2</a> <a href="/directory.php?dir=<?=$row[3]?>">LINK TO DIR 3</a> </body> </html> The Directory page: directory.php <?php $dir = $_GET['dir']; $handle = opendir($dir); if ($handle) { while (false !== ($entry = readdir($handle))) { if ($entry != "." && $entry != "..") { echo "$entry\n"; } } closedir($handle); } ?> That is a basic look at how you can achieve the desired result. Quote Link to comment https://forums.phpfreaks.com/topic/262422-field-type-for-file-directories/#findComment-1345199 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.