0

I have small project in which i am working with tables inside tabs. In the last table I am trying to call news.php file which will show all the news inside table but no results is showing here. Can anyone know where i am doing wrong? ANd how to call news.php file inside div ? Thanks. Here is my code:

<?php
// -- REGISTER ERSTELLEN -------------------------------------------------------

$page['register-fahrzeuge'] = array(
    1   => array( 'Fahrzeug','aktiv',$page['script'],'',''),
    0   => array( 'Edit-Fahrzeug','aktiv',$page['script'],'',''),   
);

$page['register-news'] = array(
    1   => array( 'News','aktiv',$page['script'],'',''),
);



// -- HTML AUSGEBEN ------------------------------------------------------------
$page['content'] .= '

<table width="538" cellspacing="0" cellpadding="0" border="0" >
    <tr>
        <td>
            <div>'.CreateRegister($page['register-news']).'</div>
            '.CreateMessage().'
            <div class="cont-liste-verlauf register">
                <?php
                require ("news.php");
                ?>
            </div>
        </td>
    </tr>
</table>';
?>
user3702602
  • 139
  • 3
  • 16
  • See this answer for storing the result from a file to a variable. http://stackoverflow.com/questions/2830366/require-once-to-variable You can then put that variable into your string. – TMH Jun 04 '14 at 13:01

3 Answers3

0

You need to do this:

$page['content'] .= '

<table width="538" cellspacing="0" cellpadding="0" border="0" >
    <tr>
        <td>
            <div>'.CreateRegister($page['register-news']).'</div>
            '.CreateMessage().'
            <div class="cont-liste-verlauf register">'.require ("news.php").' </div>
        </td>
    </tr>
</table>';

You cann't use <?php tag inside a <?php tag again so remove this

Code Lღver
  • 15,573
  • 16
  • 56
  • 75
  • Hello i have tried in both the ways but its giving error as : Fatal error: main() [function.require]: Failed opening required 'news.php ' (include_path='./:/www/1/lang:/www/1/html/admin/includes/addons:/www/1/html/admin/includes/addons/pmail:/www/1/html/admin/includes/addons/fzsuche') in /www/1/html/admin/includes/dashboard.inc – user3702602 Jun 04 '14 at 13:06
  • 3
    Did you read the error ? You have to put the path to your "news.php" file correctly. – Vincent Decaux Jun 04 '14 at 13:08
  • @user3702602 it means there is more then one file with the same name so you need to give the full path of this file which you want to include. – Code Lღver Jun 04 '14 at 13:16
0

Change your code as follows,

<?php
// -- REGISTER ERSTELLEN -------------------------------------------------------

$page['register-fahrzeuge'] = array(
    1   => array( 'Fahrzeug','aktiv',$page['script'],'',''),
    0   => array( 'Edit-Fahrzeug','aktiv',$page['script'],'',''),   
);

$page['register-news'] = array(
    1   => array( 'News','aktiv',$page['script'],'',''),
);



// -- HTML AUSGEBEN ------------------------------------------------------------
$page['content'] .= '

<table width="538" cellspacing="0" cellpadding="0" border="0" >
    <tr>
        <td>
            <div>'.CreateRegister($page['register-news']).'</div>
            '.CreateMessage().'
            <div class="cont-liste-verlauf register">'.

                require ("news.php").'

            </div>
        </td>
    </tr>
</table>';
?>
Dushyant Joshi
  • 3,672
  • 3
  • 28
  • 52
0

I was making mistake in defining php file. Here is the answer:

$page['content'] .= '

<table width="538" cellspacing="0" cellpadding="0" border="0" >
    <tr>
        <td>
            <div>'.CreateRegister($page['register-news']).'</div>
            '.CreateMessage().'
            <div class="cont-liste-verlauf register">'.require ("news.php").' </div>
        </td>
    </tr>
</table>';
random_user_name
  • 25,694
  • 7
  • 76
  • 115
user3702602
  • 139
  • 3
  • 16