Append file ext to returned query

Hi - I have this working

while($row=mysql_fetch_array($result))
{
$filename=$row['cat_title'];
echo "<li><a href=\"". $filename. "\">". $filename."</a></li>\n";
}


I need to append ".html" (the extension) onto $filename so it returns

pagename.html


How to append this in PHP please?, and thanks for your time.
Mikii [ Do, 17 Januar 2008 13:30 ] [ ID #1910737 ]

Re: Append file ext to returned query

"Mikii" <notspam [at] nomailhere.com> wrote in message
news:lTHjj.82140$wD5.40455 [at] newsfe3-gui.ntli.net...
> Hi - I have this working
>
> while($row=mysql_fetch_array($result))
> {
> $filename=$row['cat_title'];
> echo "<li><a href=\"". $filename. "\">". $filename."</a></li>\n";
> }
>
>
> I need to append ".html" (the extension) onto $filename so it returns
>
> pagename.html

$filename . ".html" ?

--
Richard.
rf [ Do, 17 Januar 2008 13:40 ] [ ID #1910738 ]

Re: Append file ext to returned query

"rf" <rf [at] invalid.com> wrote in message
news:G0Ijj.4481$421.3063 [at] news-server.bigpond.net.au...
>
> "Mikii" <notspam [at] nomailhere.com> wrote in message
> news:lTHjj.82140$wD5.40455 [at] newsfe3-gui.ntli.net...
>> Hi - I have this working
>>
>> while($row=mysql_fetch_array($result))
>> {
>> $filename=$row['cat_title'];
>> echo "<li><a href=\"". $filename. "\">". $filename."</a></li>\n";
>> }
>>
>>
>> I need to append ".html" (the extension) onto $filename so it returns
>>
>> pagename.html
>
> $filename . ".html" ?
>
> --
> Richard.


Thanks Richard for reading:
echo "<li><a href=\"". $filename . ". html" "\">". $filename."</a></li>\n"

gives parse error unexpected T_CONSTANT_ENCAPSED. Is this an escaping issue?
Mikii [ Do, 17 Januar 2008 13:53 ] [ ID #1910739 ]

Re: Append file ext to returned query

Mikii wrote:

> Hi - I have this working
>
> while($row=mysql_fetch_array($result))
> {
> $filename=$row['cat_title'];
> echo "<li><a href=\"". $filename. "\">". $filename."</a></li>\n";
> }
>
>
> I need to append ".html" (the extension) onto $filename so it returns
>
> pagename.html
>
>
> How to append this in PHP please?, and thanks for your time.

Just add it to the text string (inside the unescaped "'s):

echo "<li><a href=\"". $filename. ".html\">". $filename."</a></li>\n";

--
Kim André Akerĝ
- kimandre [at] NOSPAMbetadome.com
(remove NOSPAM to contact me directly)
kimandre [ Do, 17 Januar 2008 14:08 ] [ ID #1910743 ]

Re: Append file ext to returned query

On 17/01/2008 in message <6dIjj.49118$Hc3.20300 [at] newsfe1-gui.ntli.net>
Mikii wrote:

>Thanks Richard for reading:
>echo "<li><a href=\"". $filename . ". html" "\">". $filename."</a></li>\n"
>
>gives parse error unexpected T_CONSTANT_ENCAPSED. Is this an escaping
>issue?

I would say you need another full stop / period in there after . ".html"

echo "<li><a href=\"". $filename . ". html" . "\">". $filename."</a></li>\n"

or you could run it together:

echo "<li><a href=\"". $filename . ". html\">". $filename."</a></li>\n"


--
Jeff Gaines Damerham Hampshire UK
That's an amazing invention but who would ever want to use one of them?
(President Hayes speaking to Alexander Graham Bell on the invention of the
telephone)
Jeff Gaines [ Do, 17 Januar 2008 14:30 ] [ ID #1910746 ]

Re: Append file ext to returned query

Mikii wrote:

> echo "<li><a href=\"". $filename . ". html" "\">".
> $filename."</a></li>\n"
>
> gives parse error unexpected T_CONSTANT_ENCAPSED. Is this an escaping
> issue?

echo "<li><a href=\"". $filename . ".html\">". $filename."</a></li>\n"

Or, more readably:

printf('<li>%s</li>'."\n",
$filename,
$filename);

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 18 days, 32 min.]

Gnocchi all'Amatriciana al Forno
http://tobyinkster.co.uk/blog/2008/01/15/gnocchi-allamatrici ana/
Toby A Inkster [ Do, 17 Januar 2008 14:20 ] [ ID #1910757 ]

Re: Append file ext to returned query

Jeff Gaines wrote:
> On 17/01/2008 in message <6dIjj.49118$Hc3.20300 [at] newsfe1-gui.ntli.net>
> Mikii wrote:
>
>> Thanks Richard for reading:
>> echo "<li><a href=\"". $filename . ". html" "\">".
>> $filename."</a></li>\n"
>>
>> gives parse error unexpected T_CONSTANT_ENCAPSED. Is this an escaping
>> issue?
>
> I would say you need another full stop / period in there after . ".html"
>
> echo "<li><a href=\"". $filename . ". html" . "\">".
> $filename."</a></li>\n"
>
> or you could run it together:
>
> echo "<li><a href=\"". $filename . ". html\">". $filename."</a></li>\n"
>
>

Or you could make it easier on yourself:

echo "<li><a href='$filename.html'>$filename</a></li>\n"

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex [at] attglobal.net
==================
Jerry Stuckle [ Do, 17 Januar 2008 15:05 ] [ ID #1910758 ]

Re: Append file ext to returned query

"Jerry Stuckle" <jstucklex [at] attglobal.net> wrote in message
news:XYudnauSfKxv_RLanZ2dnUVZ_v3inZ2d [at] comcast.com...
> Jeff Gaines wrote:
>> On 17/01/2008 in message <6dIjj.49118$Hc3.20300 [at] newsfe1-gui.ntli.net>
>> Mikii wrote:
>>
>>> Thanks Richard for reading:
>>> echo "<li><a href=\"". $filename . ". html" "\">".
>>> $filename."</a></li>\n"
>>>
>>> gives parse error unexpected T_CONSTANT_ENCAPSED. Is this an escaping
>>> issue?
>>
>> I would say you need another full stop / period in there after . ".html"
>>
>> echo "<li><a href=\"". $filename . ". html" . "\">".
>> $filename."</a></li>\n"
>>
>> or you could run it together:
>>
>> echo "<li><a href=\"". $filename . ". html\">". $filename."</a></li>\n"
>>
>>
>
> Or you could make it easier on yourself:
>
> echo "<li><a href='$filename.html'>$filename</a></li>\n"
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstucklex [at] attglobal.net
> ==================


I like easy :)
Thank you all.
Mikii [ Do, 17 Januar 2008 15:59 ] [ ID #1910764 ]
PHP » comp.lang.php » Append file ext to returned query

Vorheriges Thema: Getting class object information from file.
Nächstes Thema: [SOAP]Problem with namespace in Soap Header