Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Link Query Results to a Webpage? (newbie question)
I am trying to link the results from a query to a webpage. For exampe:

Results Below:

5432 Brookwood Drive  704-434-7532   www.greatparks.com
3221 Farmfield Drive     704-656-0234   www.allyoucanbe.com
1212 Dalton Rd.            704-323-9999   www.beagoodscout.com

I need a simple PHP script that will allow the user to click on the webpage
link. I would appreciate anyone that can help me. Thanks.


Rudy



Report this thread to moderator Post Follow-up to this message
Old Post
Rudy
11-16-04 11:53 PM


Re: Link Query Results to a Webpage? (newbie question)
On Tue, 16 Nov 2004 16:59:06 -0500, "Rudy" <bre@bellsouth.net> wrote:

>I am trying to link the results from a query to a webpage. For exampe:
>
>Results Below:
>
>5432 Brookwood Drive  704-434-7532   www.greatparks.com
>3221 Farmfield Drive     704-656-0234   www.allyoucanbe.com
>1212 Dalton Rd.            704-323-9999   www.beagoodscout.com
>
>I need a simple PHP script that will allow the user to click on the webpage
>link. I would appreciate anyone that can help me. Thanks.

That's just a matter of putting an <a> tag around the address, surely?

i.e. instead of

print $row['url'];

Then:

sprintf("<a href='http://%s'>%s</a>",
htmlspecialchars($row['url']));
htmlspecialchars($row['url']));

--
Andy Hassall / <andy@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool

Report this thread to moderator Post Follow-up to this message
Old Post
Andy Hassall
11-16-04 11:53 PM


Re: Link Query Results to a Webpage? (newbie question)
> sprintf("<a href='http://%s'>%s</a>",
>    htmlspecialchars($row['url']));
>    htmlspecialchars($row['url']));

Shouldn't it be:

sprintf("<a href='http://%s'>%s</a>",
urlencode($row['url']),
htmlspecialchars($row['url'])
);



Hilarion



Report this thread to moderator Post Follow-up to this message
Old Post
Hilarion
11-17-04 01:56 PM


Re: Link Query Results to a Webpage? (newbie question)
On Wed, 17 Nov 2004 11:15:51 +0100, "Hilarion" <hilarion@SPAM.op.SMIECI.pl>
wrote:
 
>
>Shouldn't it be:
>
>sprintf("<a href='http://%s'>%s</a>",
>   urlencode($row['url']),
>   htmlspecialchars($row['url'])
> );

Actually that's what I typed first, then I had a think about it and went for
htmlspecialchars. Consider:

<?php
$row['url'] = 'localhost/test.php?blah=wurble+snurble';

printf("<a href='http://%s'>%s</a>",
urlencode($row['url']),
htmlspecialchars($row['url'])
);
?>

This doesn't do what's required; rather than outputting

<a href='http://localhost/test.php?blah=wurble+snurble'>

It outputs:

<a href='http://localhost%2Ftest.php%3Fblah%3Dwurble%2Bsnurble'>

Which isn't very useful. You don't want the / and ? encoded, you need them t
o
stay as literal characters because they're part of the URL.

--
Andy Hassall / <andy@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool

Report this thread to moderator Post Follow-up to this message
Old Post
Andy Hassall
11-17-04 08:58 PM


Re: Link Query Results to a Webpage? (newbie question)
Thanks ...that helps!


Rudy


"Andy Hassall" <andy@andyh.co.uk> wrote in message
 news:ka6np0hk9054aai3ortngqn5d5ihj1j9o7@
4ax.com...
> On Wed, 17 Nov 2004 11:15:51 +0100, "Hilarion"
<hilarion@SPAM.op.SMIECI.pl>
> wrote:
> 
>
>  Actually that's what I typed first, then I had a think about it and went
for
> htmlspecialchars. Consider:
>
> <?php
> $row['url'] = 'localhost/test.php?blah=wurble+snurble';
>
> printf("<a href='http://%s'>%s</a>",
>    urlencode($row['url']),
>    htmlspecialchars($row['url'])
> );
> ?>
>
>  This doesn't do what's required; rather than outputting
>
> <a href='http://localhost/test.php?blah=wurble+snurble'>
>
>  It outputs:
>
> <a href='http://localhost%2Ftest.php%3Fblah%3Dwurble%2Bsnurble'>
>
>  Which isn't very useful. You don't want the / and ? encoded, you need
them to
> stay as literal characters because they're part of the URL.
>
> --
> Andy Hassall / <andy@andyh.co.uk> / <http://www.andyh.co.uk>
> <http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool



Report this thread to moderator Post Follow-up to this message
Old Post
Rudy
11-17-04 08:58 PM


Re: Link Query Results to a Webpage? (newbie question)
You are absolutely right about "urlencode" vs "htmlspecialchars". My mistake
. Thanx for clarification.
Of course data in DB should be allready properly urlencoded which means that
 not using any
function in "href" value is an option too (but it's better to use "htmlspeci
alchars" in case of typos
and other mistakes).
You made some typos in your code ( ");" instead of just "," in second line )
, but they are irrelevant.

Hilarion



Report this thread to moderator Post Follow-up to this message
Old Post
Hilarion
11-18-04 01:57 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PHP SQL archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:58 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.