php - Make one value a link of another -
i passing holidays.xml
table in logged_in.php
.
holidays.xml
<?xml version="1.0" encoding="iso-8859-1" ?> <rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/"> <channel> <item> <title>luxurious jamaican holidays | 40% discount on accommodation - book now!</title> <link>http://www.numyspace.co.uk/~cgel1/holidays/jamaica.html</link> <description>7 nights @ golden palm, montego bay travelling newcastle fly jamaica</description> <pubdate>sun, 13 feb 2011 11:58:17 gmt</pubdate> <guid>http://www.numyspace.co.uk/~cgel1/holidays/jamaica.html</guid> </item> </channel> </rss>
logged_in.php
<?php // load xml file simplexml instance variable $holiday = simplexml_load_file('holidays.xml'); // draw table , column headers echo "<table border=\"0\">"; /* echo " <th>title</td> <th>link</td> <th>description</td> <th>published date</th>"; */ // iterate through item nodes displaying contents foreach ($holiday->channel->item $holiday) { echo "<tr>"; echo "<td>{$holiday->title}</td>"; echo "<td>{$holiday->link}</td>"; echo "<td>{$holiday->description}</td>"; echo "<td>{$holiday->pubdate}</td>"; echo "</tr>\n"; } echo "</table>"; ?>
i echo "<td>{$holiday->link}</td>";
link of echo "<td>{$holiday->title}</td>";
, link href , title title. there simple way this?
echo "<td><a href=\"{$holiday->link}\">{$holiday->title}</a></td>";
Comments
Post a Comment