Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

sqldatasource dal, wwwxxxenden, convert raid5 to raid 10 mdadm, apache force chunked, nrao wwwxxx, xxxxxdup, procmail change subject header, wwwXxx not20, Wwwxxx.doks sas, linux raid resync after reboot

Links

XODOX
Impressum

#1: how to make a link only if exists

Posted on 2008-04-18 19:11:23 by 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"<td>$row[0]</td>";
echo"<td><a href=\"$row[5].pdf\">$row[1]</a></td>";
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

Report this message

#2: Re: how to make a link only if exists

Posted on 2008-04-18 20:24:54 by 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"<td>$row[0]</td>";
> echo"<td><a href=\"$row[5].pdf\">$row[1]</a></td>";
> 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 "<a href=\"$row[5].pdf\">$row[1]</a>";
}

--

//Aho

Report this message

#3: Re: how to make a link only if exists

Posted on 2008-04-19 19:28:31 by Henny Boxa

On Fri, 18 Apr 2008 20:24:54 +0200 wrote "J.O. Aho"
<user@example.net>:

>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"<td>$row[0]</td>";
>> echo"<td><a href=\"$row[5].pdf\">$row[1]</a></td>";
>> 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 "<a href=\"$row[5].pdf\">$row[1]</a>";
>}

Thank you very much indeed.

Report this message