Vidya_tr Posted April 2, 2009 Share Posted April 2, 2009 I want to write a php script to generate links dynamically. the scenario is as follows.. When I upload a file a hyperlink should be created with the file name.For each upload a hyperlink should be created. But these list of links should appear on another page. When the user clicks a button to view the list of files , the list of hyperlinks should appear. How can I write a php script for this....please help me.... Quote Link to comment https://forums.phpfreaks.com/topic/152222-help-for-creating-links-dynamically/ Share on other sites More sharing options...
KevinM1 Posted April 2, 2009 Share Posted April 2, 2009 I want to write a php script to generate links dynamically. the scenario is as follows.. When I upload a file a hyperlink should be created with the file name.For each upload a hyperlink should be created. But these list of links should appear on another page. When the user clicks a button to view the list of files , the list of hyperlinks should appear. How can I write a php script for this....please help me.... You need to store the file names in a database. Then, on the page that's supposed to display the links, loop through the database and construct the links. It's a pretty simple process, really. Quote Link to comment https://forums.phpfreaks.com/topic/152222-help-for-creating-links-dynamically/#findComment-799382 Share on other sites More sharing options...
wilco Posted April 3, 2009 Share Posted April 3, 2009 You don't necessarily need to store this information in a database, you could just write the information to a file as well. It really depends on whether or not you have access to a database, and what database. If you do, and it is the most common companion to PHP (MySQL), then I would look at the PHP PDO reference to learn how to read/write data to a database. Otherwise, look at the filesystem functions to see how to write information to a file. I would recommend looking at the fopen(), fread(), and fwrite() functions in particular. Quote Link to comment https://forums.phpfreaks.com/topic/152222-help-for-creating-links-dynamically/#findComment-800039 Share on other sites More sharing options...
Vidya_tr Posted April 3, 2009 Author Share Posted April 3, 2009 I used the database and created the hyperlinks. Now my another doubt is how to remove these links when a DELETE button near the link is clicked. The link should disppear when I click the DELETE button.(For each link I have a DELETE button) and when I delete the first link others should move up and so on... Quote Link to comment https://forums.phpfreaks.com/topic/152222-help-for-creating-links-dynamically/#findComment-800172 Share on other sites More sharing options...
Daniel0 Posted April 3, 2009 Share Posted April 3, 2009 You don't necessarily need to store this information in a database, you could just write the information to a file as well. A flat file is a database as well. A database is any type of system that stores a collection of data. Quote Link to comment https://forums.phpfreaks.com/topic/152222-help-for-creating-links-dynamically/#findComment-800242 Share on other sites More sharing options...
KevinM1 Posted April 3, 2009 Share Posted April 3, 2009 I used the database and created the hyperlinks. Now my another doubt is how to remove these links when a DELETE button near the link is clicked. The link should disppear when I click the DELETE button.(For each link I have a DELETE button) and when I delete the first link others should move up and so on... This is slightly more difficult, but not by much. First, all of your stored hyperlinks should have an id associated with them. The most typical type of id is a simple number. So, you should have something like: link_id link_address --- --- 1 http://www.google.com 2 http://www.cnn.com Each DELETE button is then associated with that hyperlink's id. When the button is pushed, that id value is then passed to the script that handles the actual deletion, and is used in finding the hyperlink itself. Quote Link to comment https://forums.phpfreaks.com/topic/152222-help-for-creating-links-dynamically/#findComment-800463 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.