Jump to content

help for creating links dynamically..


Vidya_tr

Recommended Posts

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....

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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...

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.