Home > Archive > PHP DB > December 2004 > 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 |
How to build a dinamic link...
|
|
| Daniel A. Betancourt 2004-12-27, 3:55 pm |
| Hi there!!!
This is one of my first postings to this list. I spend most of the time reading the postings, but now I need to ask:
How to build a link dinamicly from an output of a query to a web page?
Much clearly. I need that certain user can upload a text content into the web site. It doesn´t have to be made in a web format or design, it would be enough as a simple text. To do this I provide him with a form based in a database. That content will be save directly into a database (MySQL). There are other web page made in PHP that using a query will show the new text introduced by the user. The matter is that the user will introduce diferent contents on a diferent subjects, that is why I need that a link is generated authomaticly pointing to each web page that has being updated by that user. Taking into account that each new text is referenced as a row in the database.
I thought that asking through the formulary for a name of the new link to the new content and then working with variables in a loop...... how to force a link to show up on a web page pointing to the propiate place authomaticly every time that a content is introduced for a new web page?
I hope you understood my question.
Thank´s you all....
Regards....
Daniel...
NOTE: Please forgive my Englihs Grammar. I´m doing the best I can. I speak Spanish.
| |
| Frank M Flynn 2004-12-28, 3:55 am |
| Hola,
I think what you want would be like this:
Let's say your table has these fields: id, title, authorID, category
and article (which is the text).
so the first query might be - SELECT id, title, category FROM myTable
WHERE authorID = $myID
and you want to know how to present a list of his articles so the user
can click one and be taken to the detail page where they can see their
article body, yes?
I assume you can run the query and display the results - so the only
exotic thing here is:
while ($row = mysql_fetch_array($result))
{
print "<tr><td><A HREF='detail.php?id=" . $row["id"] . "'>" .
$row["title"] . "</A></td><tr>";
}
This will produce a list of titles (in table rows) that are linked to
a page called "detail.php" and each title will 'GET' on this page the
id of that record with that title. So make a page called "detail.php"
that will display the body of an article given it's ID.
I've been kind of brief here - but if you need more details please ask.
Frank
On Dec 27, 2004, at 5:23 PM, php-db-digest-help@lists.php.net wrote:
> From: "Daniel A. Betancourt" <dabet@infosol.gtm.sld.cu>
> Date: December 27, 2004 2:25:11 AM PST
> To: <php-db@lists.php.net>
> Subject: How to build a dinamic link...
> Reply-To: "Daniel A. Betancourt" <dabet@infosol.gtm.sld.cu>
>
>
> Hi there!!!
> This is one of my first postings to this list. I spend most of the
> time reading the postings, but now I need to ask:
> How to build a link dinamicly from an output of a query to a web page?
>
> Much clearly. I need that certain user can upload a text content into
> the web site. It doesn´t have to be made in a web format or design, it
> would be enough as a simple text. To do this I provide him with a form
> based in a database. That content will be save directly into a
> database (MySQL). There are other web page made in PHP that using a
> query will show the new text introduced by the user. The matter is
> that the user will introduce diferent contents on a diferent subjects,
> that is why I need that a link is generated authomaticly pointing to
> each web page that has being updated by that user. Taking into account
> that each new text is referenced as a row in the database.
>
> I thought that asking through the formulary for a name of the new link
> to the new content and then working with variables in a loop...... how
> to force a link to show up on a web page pointing to the propiate
> place authomaticly every time that a content is introduced for a new
> web page?
>
> I hope you understood my question.
> Thank´s you all....
>
> Regards....
> Daniel...
>
> NOTE: Please forgive my Englihs Grammar. I´m doing the best I can. I
> speak Spanish.
>
| |
| Daniel A. Betancourt 2004-12-29, 8:55 pm |
| Hi Frank:
Thank´s for answering.
>I assume you can run the query and display the results
Yes, I can run the query very well.
>- so the only exotic thing here is:
>
>while ($row = mysql_fetch_array($result))
>{
>print "<tr><td><A HREF='detail.php?id=" . $row["id"] . "'>" . $row["title"] . "</A></td><tr>";
>}
>
>This will produce a list of titles (in table rows) that are linked to a page called "detail.php" and each title will 'GET' on this >page the id of that record with that title. So make a page called "detail.php" that will display the body of an article given it's >ID.
In that page I assume that there is another query to SELECT body FROM a given table WHERE ID='$ID';
Isn't that so?
Regards...
Daniel...
|
|
|
|
|