Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Jun 2010
    Posts
    68
    Thanks
    1
    Thanked 0 Times in 0 Posts

    How can I call another php snippet inside PHP code?

    This code snippet is already inside the <?php ?> tags. I wanted to keep this seperatly as like a "display" file. Because I have multiple pages using the exact same thing and its a pain to keep going through and updating the exact same thing. I would like to just call this piece into PHP. Is there anyway I can do this?


    PHP Code:
    echo "<center><table border=1 bgcolor=white >
    <tr>
    <th><h1>Username</h1>
    <a href=playersudesc.php>desc</a>, <a href=playersuasc.php>asc</a>
    </th>
    <th bgcolor=#C0CFFA>
    <img src=/images/xbc.png>
    <br>
    <a href=playersxbcdesc.php>desc</a>, <a href=playersxbcasc.php>asc</a>
    </th>
    <th bgcolor=#C9FFC2>
    <img src=/images/xlink2.png>
    <br>
    <a href=playersxlkdesc.php>desc</a>, <a href=playersxlkasc.php>asc</a>
    </th>
    <th><h1>Team</h1>
    <a href=playerstdesc.php>desc</a>, <a href=playerstasc.php>asc</a>
    </th>
    <th>
    <h1>Console</h1> 
    <img src=/images/XBOX.png>
    <br>
    <a href=playerscdesc.php>desc</a>, <a href=playerscasc.php>asc</a>
    </th>
    <th><h1>Location</h1>
    <img src=/images/globe.png>
    <br>
    <a href=playersldesc.php>desc</a>, <a href=playerslasc.php>asc</a>
    </th>
    <th><h1>Bandwidth</h1>
    <img src=/images/bandwidth.png>
    <br>
    <a href=playersbdesc.php>desc</a>, <a href=playersbasc.php>asc</a>
    </th>
    </tr>"
    ;

    while(
    $row mysql_fetch_array($result))
      {
      echo 
    "<tr>";
      echo 
    "<td>" $row['fid4'] . "</td>";
      echo 
    "<td bgcolor=#C0CFFA>" $row['fid5'] . "</td>";
      echo 
    "<td bgcolor=#C9FFC2>" $row['fid6'] . "</td>";
      echo 
    "<td>" $row['fid9'] . "</td>";
      echo 
    "<td>" $row['fid7'] . "</td>";
      echo 
    "<td>" $row['fid1'] . "</td>";
      echo 
    "<td>" $row['fid8'] . "</td>";
      echo 
    "</tr>";
      }
    echo 
    "</table>";

    mysql_close($con); 

  • #2
    Senior Coder Rowsdower!'s Avatar
    Join Date
    Oct 2008
    Location
    Some say it's everything.
    Posts
    2,027
    Thanks
    5
    Thanked 397 Times in 390 Posts
    Yes, you are looking for the include() function.
    The object of opening the mind, as of opening the mouth, is to shut it again on something solid. G.K. Chesterton
    See Mediocrity in its Infancy
    It's usually a good idea to start out with this at the VERY TOP of your CSS: * {border:0;margin:0;padding:0;}
    Seek and you shall find... basically:
    validate your markup | view your page cross-browser/cross-platform | free web tutorials | free hosting

  • Users who have thanked Rowsdower! for this post:

    bruceleejr (06-18-2010)

  • #3
    New Coder
    Join Date
    Jun 2010
    Posts
    68
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Okay so I would create a new file called "display.php" and then wrap the current code around php tags, and do something like:

    PHP Code:
    include("display.php"); 

    Correct~???

  • #4
    Senior Coder Rowsdower!'s Avatar
    Join Date
    Oct 2008
    Location
    Some say it's everything.
    Posts
    2,027
    Thanks
    5
    Thanked 397 Times in 390 Posts
    Quote Originally Posted by bruceleejr View Post
    Okay so I would create a new file called "display.php" and then wrap the current code around php tags, and do something like:

    PHP Code:
    include("display.php"); 

    Correct~???
    Precisely!
    The object of opening the mind, as of opening the mouth, is to shut it again on something solid. G.K. Chesterton
    See Mediocrity in its Infancy
    It's usually a good idea to start out with this at the VERY TOP of your CSS: * {border:0;margin:0;padding:0;}
    Seek and you shall find... basically:
    validate your markup | view your page cross-browser/cross-platform | free web tutorials | free hosting

  • #5
    New Coder
    Join Date
    Jun 2010
    Posts
    68
    Thanks
    1
    Thanked 0 Times in 0 Posts
    wooo hoo~!! WORKED PERFECTLY~!! thanks


  •  

    Posting Permissions

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