![]() |
![]() |
||||||
|
|||||||
| Tags: links, 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? |
| Sponsored Links |
|
|||
|
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' ![]() |
|
|||
|
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 |
|
|||
|
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. |
|
|||
|
.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 |
|
|||
|
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' ![]() |
|
|||
|
.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 |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
- Contact Us
-|-
Adobe Dreamweaver Forums -|-
Archive -|-
Top -|-Rules/Disclaimer-|-Help/Support-|-Advertise