/    Sign up×
Community /Pin to ProfileBookmark

PHP and XSLT incrementing variables

Hi there,

I have a system the loads some Lesson’s from a MySQL database and then displays them as links on a web page. When a link is pressed it is supposed to goto a new page containing information about the lesson that was clicked.

I have most things working except for being able to distinguish between the lesson numbers with the links.

[CODE]
<xsl:for-each select=”lesson”>
<tr>
<td style=”text-indent:10px”>
<a href=’readDB.php?lesson=2′> <xsl:value-of select=’title’ /></a>
</td>
</tr>
</xsl:for-each>
[/CODE]

Above is the bit of code I am having troubles with. Where the link is currently hardcoded to look for lesson=2, I would like to make it so it loads those up automatically. So it would change the lesson=x to whatever the lesson number in, 1 through to x. Similar to how a for loop would work in a desktop programming language.

I have tried to embed PHP code into this XSL stylesheet but it doesn’t seem to work due to being processed on the client and PHP is processed on the server.

Does anyone know how to dynamically increment a variable in XSLT or is there a way to embed PHP into this stylesheet?

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @tyelford spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...