fatal error when I run this php code -


i want connect php tpl.

but gives me fatal error when try run.

i added smarty php show data on tpl file still has problem.

<?php include('developer.php'); if( $xml = simplexml_load_file(url)) { foreach($xml->campaign $campaigns)  {    $camp_name = $campaignsl->name; $camp_dec= $campaigns->description; $camp_payout= $campaigns->payout; $camp_url= $campaigns->url; $smarty->assign( 'camp_name', $camp_name); $smarty->assign( 'camp_dec', $camp_dec); $smarty->assign( 'camp_payout', $camp_payout); $smarty->assign( 'camp_url', $camp_url); $smarty->display('link.tpl'); } } ?> 

and tpl file (link.tpl).

<table width="100%" class="widget-tbl"> <tr class="titles"> <td align="center">name</td> <td align="center">description</td> <td align="center">amount</td> <td align="center">link</td> </tr> <tbody id="tablelist"> {foreach item=item from=$campaigns} <tr> <td align="center">{$camp_name}</td> <td align="center">{$camp_dec}</td> <td align="center">{$camp_payout}</td> <td align="center">{$camp_url}</td> </tr> {/foreach}     </tbody> 

first problem $url variable (as pointed @maxime-lorant) in following statement:

if( $xml = simplexml_load_file($url)) // use $url not url 

second, you're doing $camp_name = $campaignsl->name; , $campaignsl undefined!

third, you're not assigning $campaign smarty template , executing loop on it.

try following:

if( $xml = simplexml_load_file($url)) {     $smarty->assign('campaigns', $xml->campaign);     $smarty->display('link.tpl'); } 

then in template:

{foreach item=item from=$campaigns}     <tr>         <td align="center">{$item->name}</td>         <td align="center">{$item->description}</td>         <td align="center">{$item->payout}</td>         <td align="center">{$item->url}</td>     </tr> {/foreach} 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -