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 3 of 3
  1. #1
    New Coder
    Join Date
    Aug 2013
    Posts
    11
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question My looping table loops twice?

    I have a table that fills itself with info from MySQL, it works and all, but it creates two tables with all the info? Not sure why..

    Here's the full page code:

    PHP Code:
    <?php
    session_start
    ();

    $username $_SESSION['username'];
    $_SESSION['csskey'] = "DontStealMyStuff";
    $userID $_SESSION['userID'];
    if (
    strlen($username) >= 1) {

    include(
    "../account/data/db_connect.php");
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">

     <head>
        <meta charset="utf-8">
        <!-- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> -->

        <title>IP Logs</title>

        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />

        <link href='http://fonts.googleapis.com/css?family=Lato:300,400,700,300italic,400italic|Raleway:400,300,700' rel='stylesheet' type='text/css'>
        <link rel="stylesheet" href="../css/bootstrap.min.css">
        <link rel="stylesheet" href="../css/icomoon.css">
        <link rel="stylesheet" href="../css/main.php">
        <link rel="stylesheet" href="../css/colors/red.css">
        <link rel="stylesheet" href="../css/animate.min.css">

        <script src="../js/other.min.js"></script>
    </head>
     
    <?php
        
    include '../nav2.html';
    ?>

            <!-- START HEADER BAR -->
        <div class="top-bar">
            <span class="nav-trigger" data-icon="&#xe005;">Menu</span>
            <div class="container">
                <div><b>Logs</b></div>
            </div>
        </div>
        <!-- END HEADER BAR -->
        
        <!-- START HEADER -->
        <header class="main-head" id="header">
            <!-- START MAIN SlIDER -->
            <div class="sl-slider-wrapper main-slider">

            </div>
        </header>
            <!-- END MAIN SlIDER -->

    <br/>
    <br/>
    <div class="main-head">
            <!-- END MAIN SlIDER -->
            <br/>
            <br/>
            <br/>
            <br/>

            <br/>
            <center>
                <div id="ABOUT">
                    <div id="logsgrey">
                        <div id="aboutcontent">
                            These are the accumulative logs of visited ip addresses using your ip-tracking pages created with ipbite.
                        </div>
                            <div id="aboutred">
                                <div id="abouttitle">
                                        <center>What are these logs<font size="4">?</font></center>
                                </div>
                            </div>
                    </div>
                </div>
                
            <br/>

    <h1>IP Tracker Report</h1>
    <div id="logs">
    <?php
      $sql 
    "SELECT DISTINCT(ip_address) FROM visitor_tracking";
      
    $result mysql_query($sql)or die(mysql_error());
     
      while(
    $info mysql_fetch_array($result)){
     
      
    $scale $info['ip_address'];
     
      
    $sql_scale "SELECT * FROM visitor_tracking WHERE visitor_id='".$userID."'";
      
    $result_scale mysql_query($sql_scale)or die(mysql_error());
     
      echo 
    "<div style='width: 100%; text-align: center;'>";                   
      echo 
    "<table style='margin: auto auto;'>";
      echo 
    "<tr><th>IP Address</th><th>Page Name</th></tr>";

    $test $row[timestamp];
    $start strtotime($test);

      while(
    $row mysql_fetch_array($result_scale)){
       
       
    $name     $row['ip_address'];
       
    $scale    $row['visitor_id'];
       
    $desc     $row['page_name'];
      
       
    // Now for each looped row
      
       
    echo "<tr><td style='width: 200px;'>".$name."</td><td style='width: 600px;'>".$desc."</td></tr>";
      
      } 
    // End our scale while loop
     
    echo "</table><br /><br /></div>";
    // End our master loop
    ?>
    </div>
            
            <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
            <script src="../js/main.js"></script>

    </body>
    <?php
    }
    else {
        
    header("location:../account/login.html?error=mustlogin");
    }
    ?>

  • #2
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,838
    Thanks
    2
    Thanked 160 Times in 155 Posts
    Move these lines up prior to the starting of the loop.
    Code:
      echo "<div style='width: 100%; text-align: center;'>";                   
      echo "<table style='margin: auto auto;'>";
      echo "<tr><th>IP Address</th><th>Page Name</th></tr>";

  • Users who have thanked FishMonger for this post:

    weCode (08-18-2013)

  • #3
    New Coder
    Join Date
    Aug 2013
    Posts
    11
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by FishMonger View Post
    Move these lines up prior to the starting of the loop.
    Code:
      echo "<div style='width: 100%; text-align: center;'>";                   
      echo "<table style='margin: auto auto;'>";
      echo "<tr><th>IP Address</th><th>Page Name</th></tr>";
    Thank you that worked! Thanked


  •  

    Posting Permissions

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