Jump to content

Recommended Posts

After several attempts, I now have data displayed on my index.php page, but the data is from all rows. Luckily I have two rows. The page also has a menu - with two links.

What I would like help with is:

How to display index.php with just the data for it - i.e. home page data.

How to display data if either the ‘home’ or ‘copyright’ links are clicked.

I understand you can use $_GET[‘id’], and isset(), but I don’t know how to do that.

I include the full html page code:

<?php
// database connection
require_once('admin/databasecon.php');

?>
<!DOCTYPE html>
<html>

  <?php include 'includes/headsection.php'; ?>

  <body>

    <?php
    // displaying data
    $table = "pages";  // table
    $sqli = "SELECT * FROM $table ORDER BY id ASC";
    $result = $conn->query($sqli);
    ?>

    <!-- topMenu -->
    <table id="topMenu">

      <tr>
        <td><h1 class="siteName">Scarab Beetle</h1></td>

        <?php

        if ($result = mysqli_query($conn, $sqli)) {
          while($row = $result->fetch_assoc()) {
              echo  "<td class='navItem'>" . "<a href=index.php>" . $row["menuheader"] . "</a>" . "</td>";
          }
        }

        ?>
      </tr>

    </table>
    <!-- topMenu end -->

    <!-- timeline menu -->
     Menu goes here
    <!-- timeline menu end -->

    <!-- page title -->
    <?php

    if ($result = mysqli_query($conn, $sqli)) {
      while($row = $result->fetch_assoc()) {
          echo  "<h1 class='centered'>" . $row["pageheader"] . "</h1>";
      }
    }

    ?>

    <hr>

    <!-- page content -->
    <?php

    if ($result = mysqli_query($conn, $sqli)) {
      while($row = $result->fetch_assoc()) {
          echo  $row["pagetext"];
      }
    }

    ?>

    <hr>

    <div class="clear"></div>

    <!-- footer content -->
    <?php include 'includes/footersection.php'; ?>
    <!-- footer content end -->

  </body>

</html>

Any help to achieve what I want will be appreciated. Thank you.

Link to comment
https://forums.phpfreaks.com/topic/312619-displaying-data-using-href-by-_getid/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.