Announcement

Collapse
No announcement yet.

php include question

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • php include question

    Ok- I have a script that generates a table from a database when called. I have put that script in a html box on the page. Below is the script:
    PHP Code:
    <?php
    //Declare and assign variable
    $pg_genre addslashes($_GET['pg_genre']);
    //
    //Now open file
    if(!file_exists("listing_db.txt"))
    {
    echo
    "<table width=550 align=center>";
    echo
    "<tr>";
    echo
    "<td class='th tc ol fw fc'>NO RECORDS AT THIS TIME</td>";
    echo
    "<tr>";
    echo
    "<td class='th tc ol fw fc'>CHECK BACK LATER</td>";
    echo
    "</tr>";
    exit;
    }
    echo
    "<div style=\"border:3px #ccdd88 solid; width:580px; height:400px; overflow:auto;\">";
    echo
    "<table border=6 align=center width=550 cellpadding=2 cellspacing=2>";
    echo
    "<tr>";
    echo
    "<th class='th tc ol fw fc'>Welcome to 123GPP Businesses and Services Directory</th>";
    echo
    "</tr>";
    //
    $openedfile fopen"listing_db.txt"'r' );
    if(
    $openedfile)
    {
    while (!
    feof$openedfile ) )
        {
            
    $line trim(fgets$openedfile ));
            if ( !empty( 
    $line ) )
            {
                list( 
    $genre,$entry1,$entry2$entry3$entry4$entry5$entry6,) = explode"|"$line );
    //////////////////////////////////
    //Now check to see which ones match the link and then post them in the table
    //
    if($genre == $pg_genre)
    {
    echo
    "<tr class=>";
    echo
    "<td class='td tc w2 fw ol ff'>$entry1</td>";
    echo
    "</tr>";
    echo
    "<tr>";
    echo
    "<td class='td tc w2'>$entry2</td>";
    echo
    "</tr>";
    echo
    "<tr>";
    echo
    "<td class='td tc w2 fw fc'>$entry3</td>";
    echo
    "</tr>";
    echo
    "<tr>";
    echo
    "<td class='td tc w2'>$entry4</td>";
    echo
    "</tr>";
    echo
    "<tr>";
    echo
    "<td class='td tc w2'>$entry5</td>";
    echo
    "</tr>";
    echo
    "<tr>";
    echo
    "<td class='td tc w2'><a href='$entry6'>$entry6</td>";
    echo
    "</tr>";
    echo
    "</div>";
    }
    }
    }
    fclose$openedfile );
    }
    else
    {
    echo
    "<tr>";
    echo
    "<td class='th w2'>Cannot open file!</td>";
    echo
    "</tr>";
    echo
    "</table>";
    }
    ?>
    I also have a header that is called using the include function. So I opened a html box and placed this inside:
    PHP Code:
    <?php
    include("gppheader.php");
    ?>
    But each time the link calls upon the page to create the table- the header is included in the table??????
    Must the table be seperated and placed in a I-Frame?
    Try it out- choose a link here
    Andy
    PHP- is a blast!

  • #2
    Re: php include problem.

    I suspect that I wil have to seperate the php code from the html table in order to accomplish this- am I on the right track?

    Andy
    PHP- is a blast!

    Comment


    • #3
      Re: php include problem.

      Hi Andy,

      if($genre == $pg_genre)
      {
      echo
      "<tr class=>"
      ;
      echo
      "<td class='td tc w2 fw ol ff'>$entry1</td>"
      ;
      echo
      "</tr>"
      ;
      echo
      "<tr>"
      ;
      echo
      "<td class='td tc w2'>$entry2</td>"
      ;
      echo
      "</tr>"
      ;
      echo
      "<tr>"
      ;
      echo
      "<td class='td tc w2 fw fc'>$entry3</td>"
      ;
      echo
      "</tr>"
      ;
      echo
      "<tr>"
      ;
      echo
      "<td class='td tc w2'>$entry4</td>"
      ;
      echo
      "</tr>"
      ;
      echo
      "<tr>"
      ;
      echo
      "<td class='td tc w2'>$entry5</td>"
      ;
      echo
      "</tr>"
      ;
      echo
      "<tr>"
      ;
      echo
      "<td class='td tc w2'><a href='$entry6'>$entry6</td>"
      ;
      echo
      "</tr>"
      ;
      echo
      "</div>";

      echo"</table>";

      You have missed the last line that closes the table, so it also takes the "include" and adds it in the table div.
      Navaldesign
      Logger Lite: Low Cost, Customizable, multifeatured Login script
      Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
      DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
      Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

      Comment


      • #4
        Re: php include problem.

        Got it fixed. Had to place the closing </table> then the closing </div>


        Thanks Naval!!

        Andy
        PHP- is a blast!

        Comment


        • #5
          Re: php include problem.

          Ok- another problem croped up. Here is the entire page code as taken from the page html window:
          <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
          <html>
          <head>
          <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
          <title>123GPP data base display</title>

          <style>
          .th{background:#ccdd88;}
          .td{background:#fffff0;}
          .ff{background:#ffde5e;}
          .tr{text-align:center;}
          .ol{font-size:18px;}
          .fw{font-weight:bloder;}
          .fc{color:#0000ff;}
          .tc{text-align:center;}
          .w1{width:100px;}
          .w2{width:600px;}
          .w3{width:400px}
          </style>

          <meta name="AUTHOR" content="123gpp.com">
          <meta name="GENERATOR" content="Created by BlueVoda">
          <style type="text/css">
          div#container
          {
          width: 800px;
          position: relative;
          margin-top: 0px;
          margin-left: auto;
          margin-right: auto;
          text-align: left;
          }
          body
          {
          text-align: center;
          margin: 0;
          }
          </style>
          </head>
          <body bgcolor="#FFFFFF" text="#000000">
          <div id="container">
          <div id="bv_" style="position:absolute;left:214px;top:133px;widt h:580px;height:304px;z-index:0" align="left">
          <?php
          //Declare and assign variable
          $pg_genre = addslashes($_GET['pg_genre']);
          //
          //Now open file
          if(!file_exists("listing_db.txt"))
          {
          echo"<table width=550 align=center>";
          echo"<tr>";
          echo"<td class='th tc ol fw fc'>NO RECORDS AT THIS TIME</td>";
          echo"<tr>";
          echo"<td class='th tc ol fw fc'>CHECK BACK LATER</td>";
          echo"</tr>";
          echo"</table>";
          exit;
          }
          echo"<div style=\"border:3px #ccdd88 solid; width:580px; height:300px; overflow:auto;\">";
          echo"<table border=6 align=right width=550 cellpadding=2 cellspacing=2>";
          echo"<tr>";
          echo"<th class='th tc ol fw fc'>Welcome to 123GPP Businesses and Services Directory</th>";
          echo"</tr>";
          //
          $openedfile = fopen( "listing_db.txt", 'r' );
          if($openedfile)
          {
          while (!feof( $openedfile ) )
          {
          $line = trim(fgets( $openedfile ));
          if ( !empty( $line ) )
          {
          list( $genre,$entry1,$entry2, $entry3, $entry4, $entry5, $entry6,) = explode( "|", $line );
          //////////////////////////////////
          //Now check to see which ones match the link and then post them in the table
          //
          if($genre == $pg_genre)
          {
          echo"<tr class=>";
          echo"<td class='td tc w2 fw ol ff'>$entry1</td>";
          echo"</tr>";
          echo"<tr>";
          echo"<td class='td tc w2'>$entry2</td>";
          echo"</tr>";
          echo"<tr>";
          echo"<td class='td tc w2 fw fc'>$entry3</td>";
          echo"</tr>";
          echo"<tr>";
          echo"<td class='td tc w2'>$entry4</td>";
          echo"</tr>";
          echo"<tr>";
          echo"<td class='td tc w2'>$entry5</td>";
          echo"</tr>";
          echo"<tr>";
          echo"<td class='td tc w2'><a href='$entry6'>$entry6</td>";
          echo"</tr>";
          }
          }
          }
          echo"</table>";
          echo"</div>";
          fclose( $openedfile );
          }
          else
          {
          echo"<br /><br />FILE COULD NOT BE OPENED!";
          }
          ?>
          </div>
          <div id="bv_" style="position:absolute;left:0px;top:0px;width:79 9px;height:119px;z-index:1" align="left">
          <?php
          include("gppheader.php");
          ?></div>
          <div id="bv_" style="position:absolute;left:0px;top:450px;width: 798px;height:180px;z-index:2" align="left">
          <?php
          include_once("gppfooter.php");
          ?></div>
          </div>
          </body>
          </html>
          No matter what I do- two footers are included. Have looked high and low- only one is coded into the page.

          Check it out- choose a category here on the subsequent display page- there are two footers.
          Andy
          PHP- is a blast!

          Comment


          • #6
            Re: php include problem.

            NEVER MIND- Stupid me had copied that footer info twice on the footer page. Therefore it naturally displayed twice.

            WHERE'S MY COFFEE!!!!!!!!!

            ANDY
            PHP- is a blast!

            Comment

            Working...
            X