SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Member
    Join Date
    Feb 2007
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    include php into index_welcome.tpl

    here is my problem.I have a php script and I want it to include into my index_welcome.tpl .Here is the code that I'm using in .tpl:


    PHP Code:
    <div id="right"> 
              <table width="100%" cellspacing="0" cellpadding="0"> 
                            <div class="submenu" id="sub8"> 
          <tr> 
              <td><img src="http://mysit.com/inc/img/main/news.gif" alt="" width="167" height="37" /></td></tr> 
                    <?php require "test.php"?> 
            </div></table>
    The problem is that news.gif is coming up after the script and I want it to be shown before the script (test.php) .

    Please can you help me?
    Thank you

  2. #2
    Dinah-Moe Humm mudshark's Avatar
    Join Date
    Dec 2003
    Posts
    1,072
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What's the output of test.php? Does it start by echo'ing new <tr> and <td> tags, as it should?
    Also, your div with id sub8 cannot sit right after a <table> tag, and right before a <tr> tag - that's improper nesting.

  3. #3
    SitePoint Zealot
    Join Date
    Jan 2007
    Posts
    191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Does your test.php have tr / td tags around the data to be displayed?

    PHP Code:
    <tr><td>your data</td></tr

  4. #4
    SitePoint Member
    Join Date
    Feb 2007
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    this is my test.php


    PHP Code:
    <?php
    if ( !defined('SECTION_MODE') )
    {
        
    define("PHPFOX_RUNTIME",TRUE);
        
    define("PHPFOX_DIR","");
        if (!@include_once(
    "phpfox_loader.php"))
        {
            die(
    "<b>Fatal Error:</b> Cant Load phpfox_loader.php");
        }

        if (@
    $GLOBALS['phpfox_config']['error_reporting'])
        {
            
    error_reporting(0);
        }
    }
    $usemarquee 1;
    $scrolldirection "Up";
    if (
    $usemarquee == 1) {
        echo 
    "<Marquee Behavior=\"Scroll\" Direction=\"$scrolldirection\" Height=\"140\" ScrollAmount=\"2\" ScrollDelay=\"100\" onMouseOver=\"this.stop()\" onMouseOut=\"this.start()\"><br>
        "
    ;
    }
                
    $sql1="SELECT * FROM `news_main` ORDER BY `news_date` DESC LIMIT 7";
                
    $result1=mysql_query($sql1);
                
    $endnum mysql_num_rows($result1);
                
    $ctime time();
                for(
    $i 0$i $endnum$i++) { 
                    
    $row1 mysql_fetch_array($result1);
                    
    $newsuser $row1["news_user"];
                    
    $newstotal $row1["news_votes"];
                    
    $headline $row1["news_headline"];
                    
    $headline stripslashes($headline);
                    
    $ndate $row1["news_date"];
                    
    $id $row1["news_id"];
                    
    $displaydate $ctime $ndate;
                    
    $displaydate $displaydate 60;
                    
    $displaydate round($displaydate);
                    
    $rank $i 1;
                    
                    echo 
    "
                        <p>
                        <b><a href='
    $VAR[0]/article.php?article=$id'><font size='1'>$headline</font></a></b>
                        <br /><font size='1'>Written by <b><a href='
    $VAR[0]/$newsuser'>$newsuser</a></b> - Posted $displaydate minutes ago</font>
                    "
    ;
                }
                
    ?>

  5. #5
    SitePoint Member
    Join Date
    Feb 2007
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    so can someone help me?Please....

  6. #6
    SitePoint Enthusiast -tcwd-'s Avatar
    Join Date
    Mar 2005
    Location
    Toronto, ON, Canada
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    like jgstevenson said earlier, it's because of the lack of new <tr> and <td> tags in test.php.

    Try putting "<tr><td>" at the beginning of test.php and "</td></tr>" at the end.
    - Edward Sun ..blog.. printdoublesided
    Potential client demands a portfolio, but you don't have one? ...
    Easily create your own portfolio!

  7. #7
    SitePoint Member
    Join Date
    Feb 2007
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tried it but all I get now is just the image without the stuf that I have under it...so now I get just news.gif but I dont get test.php script and none of the scripts that were runing after it...

  8. #8
    SitePoint Zealot
    Join Date
    Jan 2007
    Posts
    191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Debug

    The best way to debug stuff like this is, to make sure you can output plain text without the fancy tags. For instance, remove your <Marquee> tag, and all your <br> and <p> and just spit out text.

    If this works then you know its a problem with the tags in the table. Also, look at the source code of the browser to see if the data is even being outputted. Make sure it's in the proper table tags <tr><td></td></tr> and that no tags are being opened or closed without a matching tag.

    Does your <Marquee> need a closing tag? Or need to be <Marquee />?

    P.S. you can use single quotes for Html attributes just as you can use double quotes. Your code can be cleaner if you do all your attributes in single quotes if you are echoing a string that is encapsulated in double quotes so you won't have to escape all your double quotes. Also, it's more efficient to only echo dynamic data instead of all your static html. Just close your <?php then reopen it when you need to access php variables or do more logic.

  9. #9
    SitePoint Member
    Join Date
    Feb 2007
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tried it but It doesn't work.
    I can't remove marqu coz then the output wont scroll up.

    Please can u change the code for me and post here the correct one?
    Thnx

  10. #10
    SitePoint Zealot
    Join Date
    Jan 2007
    Posts
    191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Like I said before, you need to encapsulate your news stuff with <tr><td></td></tr>

    I just copied your code and put those tags around the news and it works.

    Index file:
    PHP Code:
    <div id="right">
        <table width="100%" cellspacing="0" cellpadding="0">
            <div class="submenu" id="sub8">
            <tr>
                <td>
                      <img src="http://tbn0.google.com/images?q=tbn:Omplzers5AVSTM:http://corz.org/dev/img/butt_dev-php.png" alt="" width="167" height="37" />
                  </td>
              </tr>
            <?php require "test2.php"?>
            </div>
        </table>
    </div>

    File to Include:
    PHP Code:
    <tr>
    <td>
    <?php
    $usemarquee 
    1;
    $scrolldirection "Up";
    $headline 'This is my stuff';
    if (
    $usemarquee == 1) {
        echo 
    "<Marquee Behavior=\"Scroll\" Direction=\"$scrolldirection\" Height=\"140\" ScrollAmount=\"2\" ScrollDelay=\"100\" onMouseOver=\"this.stop()\" onMouseOut=\"this.start()\"><br>
        "
    ;
    }
                    echo 
    "
                        <p>
                        <b><a href=''><font size='1'>
    $headline</font></a></b>
                        <br /><font size='1'>Written by <b><a href='
    $VAR[0]/$newsuser'>$newsuser</a></b> - Posted $displaydate minutes ago</font>
                    "
    ;
    ?>
    </td>
    </tr>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •