Displaying a message when there are no results from an XSL Query
Using MM_XSLTransform.class.php
I am querying an XML file to produce a list of places whose town name or address match a letter of the alphabet. The letter is passed as a variable in a URL.
XSL:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<xsl:param name="letter"/>
<xsl:output method="html" encoding="UTF-8"/>
<xsl:template match="/">
<xsl:for-each select="dataroot/CPINFOWEB[Town=starts-with(Town, $letter) or Name=starts-with(Name, $letter)]">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<a href="detail.php?park={CostCode}"><xsl:value-of select="Name"/></a><br />
<a href="detail.php?park={CostCode}"><xsl:value-of select="Town"/></a><br />
<xsl:value-of select="Address"/><br />
<br />
</td>
</tr>
</table>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Destination PHP file:
<?php
$mm_xsl = new MM_XSLTransform();
$mm_xsl->setXML("../regions/CPINFOWEB-mobile.xml");
$mm_xsl->setXSL("list.xsl");
$mm_xsl->addParameter("letter",$_GET['letter']);
echo $mm_xsl->Transform();
?>
The result Name and Town are displayed as a URL to link to a "more details" page.
All works fine, but when there are no results for a letter of the alphabet I obviously get a blank page.
How do I display a "no results" message instead