how to make a link only if exists

how to make a link only if exists

am 18.04.2008 19:11:23 von Henny Boxa

On my site is a database of articles in a few journals. The visitor
can get information by asking for the name of an author or a word in
the articles title. So far so good.
Some, but not all of the articles are in PDF. I would like to give the
visitor the opportunity to get the PDF file, but I want to present the
link only if there is a PDF file for this title. Is that possible?
At present the situation is:
while ($row=mysql_fetch_row($result))
{
echo"$row[0]";
echo"";
etcetera all relevant rows
}
As probably is clear row[0] contains authors, row[1] contains titles,
other row are used for finding place and in row[5] is the id of the
article (idart). This number is in the query but it is not presented
to the visitor. So the name of the PDF file is idart.pdf.
Should I make an if statement within the link?
Thank you,
Henny

Re: how to make a link only if exists

am 18.04.2008 20:24:54 von Shion

Henny Boxa wrote:
> On my site is a database of articles in a few journals. The visitor
> can get information by asking for the name of an author or a word in
> the articles title. So far so good.
> Some, but not all of the articles are in PDF. I would like to give the
> visitor the opportunity to get the PDF file, but I want to present the
> link only if there is a PDF file for this title. Is that possible?
> At present the situation is:
> while ($row=mysql_fetch_row($result))
> {
> echo"$row[0]";
> echo"";
> etcetera all relevant rows
> }
> As probably is clear row[0] contains authors, row[1] contains titles,
> other row are used for finding place and in row[5] is the id of the
> article (idart). This number is in the query but it is not presented
> to the visitor. So the name of the PDF file is idart.pdf.
> Should I make an if statement within the link?

if(file_exists($row[5].'.pdf')) {
echo "";
}

--

//Aho

Re: how to make a link only if exists

am 19.04.2008 19:28:31 von Henny Boxa

On Fri, 18 Apr 2008 20:24:54 +0200 wrote "J.O. Aho"
:

>Henny Boxa wrote:
>> On my site is a database of articles in a few journals. The visitor
>> can get information by asking for the name of an author or a word in
>> the articles title. So far so good.
>> Some, but not all of the articles are in PDF. I would like to give the
>> visitor the opportunity to get the PDF file, but I want to present the
>> link only if there is a PDF file for this title. Is that possible?
>> At present the situation is:
>> while ($row=mysql_fetch_row($result))
>> {
>> echo"$row[0]";
>> echo"";
>> etcetera all relevant rows
>> }
>> As probably is clear row[0] contains authors, row[1] contains titles,
>> other row are used for finding place and in row[5] is the id of the
>> article (idart). This number is in the query but it is not presented
>> to the visitor. So the name of the PDF file is idart.pdf.
>> Should I make an if statement within the link?
>
>if(file_exists($row[5].'.pdf')) {
> echo "";
>}

Thank you very much indeed.