Adobe Dreamweaver Forums



Last 10 THreads :         Unable to create SWC in Flash CS4 (Last Post : nrajbhan - Replies : 1 - Views : 2 )           »          Flash CS4 External Lirbrary (Last Post : nrajbhan - Replies : 1 - Views : 2 )           »          Opening different Flash Galleries with differentlinks... (Last Post : Nancy O - Replies : 8 - Views : 9 )           »          Favicon for context-sensitive Help (WebHelp) (Last Post : LuckyClover - Replies : 5 - Views : 6 )           »          Re: Help authenticating installer (Last Post : scarletnew - Replies : 2 - Views : 5 )           »          unlinking shared assets (Last Post : dmodie - Replies : 0 - Views : 1 )           »          Spry Accordion Panel Default State All Closed? (Last Post : Steven_K - Replies : 2 - Views : 3 )           »          Re: export image in D11 (Last Post : Applied CD - Replies : 0 - Views : 1 )           »          Re: Adobe Capture?? (Last Post : CatBandit - Replies : 0 - Views : 1 )           »          catching errors from remotely invoked processes (Last Post : Cr99 - Replies : 2 - Views : 3 )           »         


Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
User Info Statistics
Go Back   Adobe Dreamweaver Forums > Dreamweaver: Main > Dreamweaver Application Development
 
Tags: ,



Reply
  #1 (permalink)  
Old 09-01-2008, 05:27 AM
whatalotofrubbish
 
Posts: n/a
Diggs:
Default Links in PHP

I have a list of urls saved in a database recordset on a PHP page.
They are of the form
$row_Recordset1['Link_text'] and
$row_Recordset1['Link_URL']

I want to display them as a clickable hyperlink on the page
I have tried :
<?PHP echo <a
href="$row_Recordset1['Link_URL']">$row_Recordset1['Link_text']</a> ?>
and many variations on it with no success.
Can anyone give me a lead?




Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 09-01-2008, 06:47 AM
Mark A. Boyd
 
Posts: n/a
Diggs:
Default Re: Links in PHP

whatalotofrubbish posted in macromedia.dreamweaver.appdev:

> I have a list of urls saved in a database recordset on a PHP page.
> They are of the form
> $row_Recordset1['Link_text'] and
> $row_Recordset1['Link_URL']
>
> I want to display them as a clickable hyperlink on the page
> I have tried :
> <?PHP echo <a
> href="$row_Recordset1['Link_URL']">$row_Recordset1['Link_text']</a> ?>
> and many variations on it with no success.
> Can anyone give me a lead?


Do the quotes look right in the rendered html source? How about something
like this?

<?PHP echo '<a href="'. $row_Recordset1['Link_URL']. '">'
..$row_Recordset1['Link_text'] .'</a>'?>



--
Mark A. Boyd
Keep-On-Learnin'
Reply With Quote
  #3 (permalink)  
Old 09-01-2008, 02:26 PM
whatalotofrubbish
 
Posts: n/a
Diggs:
Default Re: Links in PHP

Bang on! Thanks for that.
Howard
Reply With Quote


  #4 (permalink)  
Old 09-01-2008, 03:40 PM
Gary White
 
Posts: n/a
Diggs:
Default Re: Links in PHP

On Mon, 1 Sep 2008 04:01:18 +0000 (UTC), "whatalotofrubbish"
<webforumsuser@macromedia.com> wrote:

>I have a list of urls saved in a database recordset on a PHP page.
> They are of the form
> $row_Recordset1['Link_text'] and
> $row_Recordset1['Link_URL']


printf('<a href="%s">%s</a>',
$row_Recordset1['Link_URL'],
$row_Recordset1['Link_text']);

Gary
Reply With Quote
  #5 (permalink)  
Old 09-01-2008, 06:44 PM
Mark A. Boyd
 
Posts: n/a
Diggs:
Default Re: Links in PHP

whatalotofrubbish posted in macromedia.dreamweaver.appdev:

> Bang on! Thanks for that.


You're welcome!

Note that Gary's code is MUCH better as far as readability.


--
Mark A. Boyd
Keep-On-Learnin'
Reply With Quote
  #6 (permalink)  
Old 09-01-2008, 07:51 PM
whatalotofrubbish
 
Posts: n/a
Diggs:
Default Re: Links in PHP

Both work equally well, but I don't know enough to work out how Gary's code
works.
What are the "%s" and %s bits and how do they relate to the recordset
variables? Am I right in assuming that they pick up the values from the
following recordsets? Where would I find reading to give a better
understanding? I have a PHP manual, but entering either of these in the search
field produces no results.

Reply With Quote


  #7 (permalink)  
Old 09-01-2008, 08:12 PM
whatalotofrubbish
 
Posts: n/a
Diggs:
Default Re: Links in PHP

One last point - If I need to have the link page appear in a new window, (target = "blank") how does that fit in the code?
Reply With Quote
  #8 (permalink)  
Old 09-01-2008, 08:53 PM
Michael Fesser
 
Posts: n/a
Diggs:
Default Re: Links in PHP

.oO(whatalotofrubbish)

>Both work equally well, but I don't know enough to work out how Gary's code
>works.
> What are the "%s" and %s bits and how do they relate to the recordset
>variables?


They are placeholders for strings and will be replaced with the actual
values taken from the additional arguments passed to the printf()
function after the format string. You can find details and examples in
the manual.

http://www.php.net/sprintf

Here's a little modification:

printf('<a href="%s">%s</a>',
htmlspecialchars($row_Recordset1['Link_URL']),
htmlspecialchars($row_Recordset1['Link_text'])
);

It makes sure that you'll always get valid HTML, for example if the URL
contains '&' signs. A '<' in the link text could also cause problems.

If the URLs and link texts are inserted by users, it will also help to
prevent cross-site-scripting (XSS, use Google for more details).

http://www.php.net/htmlspecialchars

Micha
Reply With Quote
  #9 (permalink)  
Old 09-01-2008, 08:53 PM
Mark A. Boyd
 
Posts: n/a
Diggs:
Default Re: Links in PHP

whatalotofrubbish posted in macromedia.dreamweaver.appdev:

> Both work equally well, but I don't know enough to work out how
> Gary's code works.


http://php.net/printf



--
Mark A. Boyd
Keep-On-Learnin'
Reply With Quote


  #10 (permalink)  
Old 09-01-2008, 08:53 PM
Michael Fesser
 
Posts: n/a
Diggs:
Default Re: Links in PHP

.oO(whatalotofrubbish)

>One last point - If I need to have the link page appear in a new window,
>(target = "blank") how does that fit in the code?


printf('<a href="%s" target="_blank">%s</a>',
...

Whether to open a new window or not is another question ...

Micha
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 06:51 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Inactive Reminders By Mished.co.uk