For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > December 2004 > Re: [PHP-DB] How to build a dinamic link...









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [PHP-DB] How to build a dinamic link...
Daniel A. Betancourt

2004-12-29, 8:55 pm

Hi TG!
First of all thank you very much for your corrections to my English. I
accept them in good faith. Finding people like yourself is great because
that way I can improve my English. If happen for you to like Spanish, I
might be able to help you no matter what the cost. Just let me know, ok?.=
I
guess that way I could learn better English.

Now, let=B4s get down to the point. As a matter of fact I haven=B4t trie=
d your
sugestions on the PHP script yet. First there are some details I need to
understand much better (is "much" well used here this time?)

> Ok, if I understand what you're asking, here's how your scripts are set

up:
> 1. One page/script lets users enter information that is then stored int=

o
> the database


That is correct.

> 2. Another page/script displays links (href links right?). One for each
> item submitted to the database


Correct.

> 3. A third page (?) displays the data or maybe the links point directly=

to
> a text file that's created on the server.


Correct again. There are several pages that will do this because there ar=
e
several tables in the Database. Each table is used for an specific user a=
nd
it=B4s data. That is why the script for one page is a little diferent fro=
m the
other due to the diferent tables.

> If this is the case, then here is what I would do:
>
> 1. Have the user enter data into a form (or do a FILE upload of a text
> file).


How can I do that?. I mean to upload a text file.

>The data is either stored in a database or the file path/location
> of th text file is stored in the database.


I would like to have the file sotred in the database, not the path. Can i=
t
be done?. How?. Although I=B4m counting on moving the Database to another
server after the PHP programming task is done. That is why I=B4m wonderin=
g if
it would be better to have the file into the database or on an specific
folder, to show it to de user through a web page every time it=B4s needed.

> 2. The "list" page will go to the database, get all the records that ma=

tch
> that user's ID (or all new items if you want to view all new items.. yo=

u
> probably want to do this by date or just show the last 20 items or
> something).


You are right again. That=B4s what I want, at least that=B4s what I=B4m i=
ntempting
to do.

>Do this with a basic database query then loop through the
> result set and display a line for each.


I don=B4t quite fallow you on this. Can you explain it a little better,
please?

>You had asked about how to create
> a dynamic link. You would probably do something like this:
>
> $filepath =3D "c:\\config.sys"; # You'd get this from your database qu=

ery
> echo "<a href=3D\"$filepath\">Click here for text file</a><br>\n";


Assigning a query to $filepath variable will assure me that when ever a n=
ew
text is uploaded, the link will point to the newest file?

> or if the text was stored in the database:
> $infoid =3D 12345; # Unique ID of the text stored in the database
> $textinfo =3D "User Entered Data 12/25/2004"; # Basic info you retriev=

ed
> from the database just to show there's a data to display
> echo "<a href=3D\"view.php?infoid=3D$infoid\">$textinfo</a><br>\n";
>
> All of that in a "for" or "foreach" loop depending on how you want to d=

o
> it and how you're retrieving data from the database.


Do you have an example you can send me, please?. That way I might underst=
and
it a little better.

> 3. View the info (view.php):
>
> $infoid =3D $_GET["infoid"];
> or...
> $filepath =3D "c:\\config.sys";
>
> This is where you'd either get the data out of the database to display,=

or
> you'd load the text file in to display.


I don=B4t know if it is better to have the file outside the database or n=
ot.
What are your recomendations on this?. I=B4m looking for the best perform=
ance
of the queries.

> That's the general idea at least. Did I answer your question?

In deed you did!!!. Thank=B4s again. I hope that this time I=B4ve used a =
better
English Grammar. Anyway, it would be better for me if you where able to
speak Spanish because taking into account that I don=B4t now much about P=
HP
and that my English in not that good, I guess that speaking Spanish is a
faster way for me to learn about PHP and it=B4s fetures. Don=B4t you thin=
k so?
>
> Take care!

You too!!.
And thank you, again.

Regards...
Daniel...
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com