Random XML Record in Spry using PHP


/ Published in: PHP
Save to your folder(s)

what was taking an embarrassingly long time in Spry took 2 lines in PHP


Copy this code and paste it in your HTML
  1. <script language="JavaScript" type="text/javascript">
  2. <?php $num=rand(1,7); ?>
  3. var ds = new Spry.Data.XMLDataSet("data_in_XML.xml","record/thing[id='<? echo $num; ?>']");
  4. </script>
  5. .
  6. .
  7. .
  8. <div spry:region="ds">
  9. <p spry:repeat="ds"><strong>{ds::title}</strong></p>
  10. <p spry:repeat="ds">{ds::desc}</p>
  11. </div>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.