Jump to content

[SOLVED] Extra <br> tags


meiamsome

Recommended Posts

hello:P i've got a problem with my php code where for some reason it returns extra line breaks. ok so here is an extract of my php:

if(!isset($_GET['id'])) {
        echo "All Games";
        echo "<table><tr><th>Name</th><th>Creator</th><th>Description</th><th>Rating</th></tr>";
        $result=mysql_query('SELECT * FROM `games` ORDER BY `game_rating` DESC LIMIT '.$base.' , '.$roof) or die("An error has occured. Please refresh the page. error: ".mysql_error());
        ?><script type="text/javascript" src="http://images.freewebs.com/JS/clicky.js"></script><script type="text/javascript">var clicky_page_title='Games on Pixelpig';startClicky(24697137,'fwdb1');</script><noscript><p><img alt="Clicky Web Analytics" src="http://in.freewebs.getclicky.com/24697137-fwdb1.gif"/></p></noscript><script>
_udn="none";

        </script><?php
} else {
    if($_GET['id']==-1) {
        ?><script type="text/javascript" src="http://images.freewebs.com/JS/clicky.js"></script><script type="text/javascript">var clicky_page_title='Our Games on Pixelpig';startClicky(24697137,'fwdb1');</script><noscript><p><img alt="Clicky Web Analytics" src="http://in.freewebs.getclicky.com/24697137-fwdb1.gif"/></p></noscript><script>
_udn="none";
</script><?php
        echo "Our Games";
        echo "<table><tr><th>Name</th><th>Creator</th><th>Description</th><th>Rating</th></tr>";
        $result=mysql_query('SELECT * FROM `games` WHERE `game_creator_num`=10 or `game_creator_num`=2 ORDER BY `game_rating` DESC LIMIT '.$base.' , '.$roof) or die("An error has occured. Please refresh the page. error: ".mysql_error());
    }
    if($_GET['id']==-2) {
        ?><script type="text/javascript" src="http://images.freewebs.com/JS/clicky.js"></script><script type="text/javascript">var clicky_page_title='Your Games on Pixelpig';startClicky(24697137,'fwdb1');</script><noscript><p><img alt="Clicky Web Analytics" src="http://in.freewebs.getclicky.com/24697137-fwdb1.gif"/></p></noscript><script>
_udn="none";
</script><?php
        echo "Your Games";
        echo "<table><tr><th>Name</th><th>Creator</th><th>Description</th><th>Rating</th></tr>";
        $result=mysql_query('SELECT * FROM `games` WHERE `game_creator_num`!=10 and `game_creator_num`!=2 ORDER BY `game_rating` DESC LIMIT '.$base.' , '.$roof) or die("An error has occured. Please refresh the page. error: ".mysql_error());
    }
    if($_GET['id']==0) {
        ?><script type="text/javascript" src="http://images.freewebs.com/JS/clicky.js"></script><script type="text/javascript">var clicky_page_title='Games on Pixelpig';startClicky(24697137,'fwdb1');</script><noscript><p><img alt="Clicky Web Analytics" src="http://in.freewebs.getclicky.com/24697137-fwdb1.gif"/></p></noscript><script>
_udn="none";
</script><?php
        echo "All Games";
        echo "<table><tr><th>Name</th><th>Creator</th><th>Description</th><th>Rating</th></tr>";
        $result=mysql_query('SELECT * FROM `games` ORDER BY `game_rating` DESC LIMIT '.$base.' , '.$roof) or die("An error has occured. Please refresh the page. error: ".mysql_error());
    }
    if($_GET['id']>0) {
        $result=mysql_query('SELECT * FROM `users` WHERE `id`='.$_GET['id']) or die("An error has occured. Please refresh the page. error: ".mysql_error());
        if(mysql_num_rows($result)==1) {
                   $user=mysql_fetch_row($result);
?><script type="text/javascript" src="http://images.freewebs.com/JS/clicky.js"></script><script type="text/javascript">var clicky_page_title='Games by <?php echo $user[1]; ?> on Pixelpig';startClicky(24697137,'fwdb1');</script><noscript><p><img alt="Clicky Web Analytics" src="http://in.freewebs.getclicky.com/24697137-fwdb1.gif"/></p></noscript><script>
_udn="none";
</script><?php
            echo "Games made by ".$user[1];
            echo "<table><tr><th>Name</th><th>Creator</th><th>Description</th><th>Rating</th></tr>";
            $result=mysql_query('SELECT * FROM `games` WHERE `game_creator_num`='.$_GET['id'].' ORDER BY `game_rating` DESC LIMIT '.$base.' , '.$roof) or die("An error has occured. Please refresh the page. error: ".mysql_error());
        } else {
            $b=0;
            echo "The user does not exist";
        }
    }
}
if($b) {
while($ok=mysql_fetch_row($result)) {
    if (strlen($ok[12]) > 100) {
    $desc = substr($ok[12], 0, strrpos(substr($ok[12], 0, 100), ' ')) . '...';
    } else {
    $desc=$ok[12];
    }
    echo "<tr><td><a href='".$_SEVER['php_self']."?page=game.php&game=".$ok[0]."'>".$ok[1]."</a></td><td>".$ok[11]."</td><td>".$desc."</td><td>".$ok[20]."</td></tr><br>";
}

and on out put it produces this:

Our Games<br><br><br><table><tbody><tr><th>Name</th><th>Creator</th><th>Description</th><th>Rating</th></tr><tr><td><a hrf="?page=game.php&game=1">The Helico

where did all the <br>'s come from?

Link to comment
Share on other sites

here is entire code:

Welcome to the Pixelpig Community, the number 1 place to share games.<br>
<?php
$b=1;
if(isset($_GET['pagenum'])) {
    $base=$_GET['pagenum']*30;
} else {
    $base=0;
}
$roof=$base+10;
if(!isset($_GET['id'])) {
        echo "All Games";
        echo "<table><tr><th>Name</th><th>Creator</th><th>Description</th><th>Rating</th></tr>";
        $result=mysql_query('SELECT * FROM `games` ORDER BY `game_rating` DESC LIMIT '.$base.' , '.$roof) or die("An error has occured. Please refresh the page. error: ".mysql_error());
        ?><script type="text/javascript" src="http://images.freewebs.com/JS/clicky.js"></script><script type="text/javascript">var clicky_page_title='Games on Pixelpig';startClicky(24697137,'fwdb1');</script><noscript><p><img alt="Clicky Web Analytics" src="http://in.freewebs.getclicky.com/24697137-fwdb1.gif"/></p></noscript><script>
_udn="none";

        </script><?php
} else {
    if($_GET['id']==-1) {
        ?><script type="text/javascript" src="http://images.freewebs.com/JS/clicky.js"></script><script type="text/javascript">var clicky_page_title='Our Games on Pixelpig';startClicky(24697137,'fwdb1');</script><noscript><p><img alt="Clicky Web Analytics" src="http://in.freewebs.getclicky.com/24697137-fwdb1.gif"/></p></noscript><script>
_udn="none";
</script><?php
        echo "Our Games";
        echo "<table><tr><th>Name</th><th>Creator</th><th>Description</th><th>Rating</th></tr>";
        $result=mysql_query('SELECT * FROM `games` WHERE `game_creator_num`=10 or `game_creator_num`=2 ORDER BY `game_rating` DESC LIMIT '.$base.' , '.$roof) or die("An error has occured. Please refresh the page. error: ".mysql_error());
    }
    if($_GET['id']==-2) {
        ?><script type="text/javascript" src="http://images.freewebs.com/JS/clicky.js"></script><script type="text/javascript">var clicky_page_title='Your Games on Pixelpig';startClicky(24697137,'fwdb1');</script><noscript><p><img alt="Clicky Web Analytics" src="http://in.freewebs.getclicky.com/24697137-fwdb1.gif"/></p></noscript><script>
_udn="none";
</script><?php
        echo "Your Games";
        echo "<table><tr><th>Name</th><th>Creator</th><th>Description</th><th>Rating</th></tr>";
        $result=mysql_query('SELECT * FROM `games` WHERE `game_creator_num`!=10 and `game_creator_num`!=2 ORDER BY `game_rating` DESC LIMIT '.$base.' , '.$roof) or die("An error has occured. Please refresh the page. error: ".mysql_error());
    }
    if($_GET['id']==0) {
        ?><script type="text/javascript" src="http://images.freewebs.com/JS/clicky.js"></script><script type="text/javascript">var clicky_page_title='Games on Pixelpig';startClicky(24697137,'fwdb1');</script><noscript><p><img alt="Clicky Web Analytics" src="http://in.freewebs.getclicky.com/24697137-fwdb1.gif"/></p></noscript><script>
_udn="none";
</script><?php
        echo "All Games";
        echo "<table><tr><th>Name</th><th>Creator</th><th>Description</th><th>Rating</th></tr>";
        $result=mysql_query('SELECT * FROM `games` ORDER BY `game_rating` DESC LIMIT '.$base.' , '.$roof) or die("An error has occured. Please refresh the page. error: ".mysql_error());
    }
    if($_GET['id']>0) {
        $result=mysql_query('SELECT * FROM `users` WHERE `id`='.$_GET['id']) or die("An error has occured. Please refresh the page. error: ".mysql_error());
        if(mysql_num_rows($result)==1) {
                   $user=mysql_fetch_row($result);
?><script type="text/javascript" src="http://images.freewebs.com/JS/clicky.js"></script><script type="text/javascript">var clicky_page_title='Games by <?php echo $user[1]; ?> on Pixelpig';startClicky(24697137,'fwdb1');</script><noscript><p><img alt="Clicky Web Analytics" src="http://in.freewebs.getclicky.com/24697137-fwdb1.gif"/></p></noscript><script>
_udn="none";
</script><?php
            echo "Games made by ".$user[1];
            echo "<table><tr><th>Name</th><th>Creator</th><th>Description</th><th>Rating</th></tr>";
            $result=mysql_query('SELECT * FROM `games` WHERE `game_creator_num`='.$_GET['id'].' ORDER BY `game_rating` DESC LIMIT '.$base.' , '.$roof) or die("An error has occured. Please refresh the page. error: ".mysql_error());
        } else {
            $b=0;
            echo "The user does not exist";
        }
    }
}
if($b) {
while($ok=mysql_fetch_row($result)) {
    if (strlen($ok[12]) > 100) {
    $desc = substr($ok[12], 0, strrpos(substr($ok[12], 0, 100), ' ')) . '...';
    } else {
    $desc=$ok[12];
    }
    echo "<tr><td><a href='".$_SEVER['php_self']."?page=game.php&game=".$ok[0]."'>".$ok[1]."</a></td><td>".$ok[11]."</td><td>".$desc."</td><td>".$ok[20]."</td></tr><br>";
}
echo "</table>";
}
?>

?Welcome to the Pixelpig Community, the number 1 place to share games.<br>

<?php

$b=1;

if(isset($_GET['pagenum'])) {

    $base=$_GET['pagenum']*30;

} else {

    $base=0;

}

$roof=$base+10;

if(!isset($_GET['id'])) {

        echo "All Games";

        echo "<table><tr><th>Name</th><th>Creator</th><th>Description</th><th>Rating</th></tr>";

        $result=mysql_query('SELECT * FROM `games` ORDER BY `game_rating` DESC LIMIT '.$base.' , '.$roof) or die("An error has occured. Please refresh the page. error: ".mysql_error());

        ?><script type="text/javascript" src="http://images.freewebs.com/JS/clicky.js"></script><script type="text/javascript">var clicky_page_title='Games on Pixelpig';startClicky(24697137,'fwdb1');</script><noscript><p><img alt="Clicky Web Analytics" src="http://in.freewebs.getclicky.com/24697137-fwdb1.gif"/></p></noscript><script>

_udn="none";

 

        </script><?php

} else {

    if($_GET['id']==-1) {

        ?><script type="text/javascript" src="http://images.freewebs.com/JS/clicky.js"></script><script type="text/javascript">var clicky_page_title='Our Games on Pixelpig';startClicky(24697137,'fwdb1');</script><noscript><p><img alt="Clicky Web Analytics" src="http://in.freewebs.getclicky.com/24697137-fwdb1.gif"/></p></noscript><script>

_udn="none";

</script><?php

        echo "Our Games";

        echo "<table><tr><th>Name</th><th>Creator</th><th>Description</th><th>Rating</th></tr>";

        $result=mysql_query('SELECT * FROM `games` WHERE `game_creator_num`=10 or `game_creator_num`=2 ORDER BY `game_rating` DESC LIMIT '.$base.' , '.$roof) or die("An error has occured. Please refresh the page. error: ".mysql_error());

    }

    if($_GET['id']==-2) {

        ?><script type="text/javascript" src="http://images.freewebs.com/JS/clicky.js"></script><script type="text/javascript">var clicky_page_title='Your Games on Pixelpig';startClicky(24697137,'fwdb1');</script><noscript><p><img alt="Clicky Web Analytics" src="http://in.freewebs.getclicky.com/24697137-fwdb1.gif"/></p></noscript><script>

_udn="none";

</script><?php

        echo "Your Games";

        echo "<table><tr><th>Name</th><th>Creator</th><th>Description</th><th>Rating</th></tr>";

        $result=mysql_query('SELECT * FROM `games` WHERE `game_creator_num`!=10 and `game_creator_num`!=2 ORDER BY `game_rating` DESC LIMIT '.$base.' , '.$roof) or die("An error has occured. Please refresh the page. error: ".mysql_error());

    }

    if($_GET['id']==0) {

        ?><script type="text/javascript" src="http://images.freewebs.com/JS/clicky.js"></script><script type="text/javascript">var clicky_page_title='Games on Pixelpig';startClicky(24697137,'fwdb1');</script><noscript><p><img alt="Clicky Web Analytics" src="http://in.freewebs.getclicky.com/24697137-fwdb1.gif"/></p></noscript><script>

_udn="none";

</script><?php

        echo "All Games";

        echo "<table><tr><th>Name</th><th>Creator</th><th>Description</th><th>Rating</th></tr>";

        $result=mysql_query('SELECT * FROM `games` ORDER BY `game_rating` DESC LIMIT '.$base.' , '.$roof) or die("An error has occured. Please refresh the page. error: ".mysql_error());

    }

    if($_GET['id']>0) {

        $result=mysql_query('SELECT * FROM `users` WHERE `id`='.$_GET['id']) or die("An error has occured. Please refresh the page. error: ".mysql_error());

        if(mysql_num_rows($result)==1) {

                  $user=mysql_fetch_row($result);

?><script type="text/javascript" src="http://images.freewebs.com/JS/clicky.js"></script><script type="text/javascript">var clicky_page_title='Games by <?php echo $user[1]; ?> on Pixelpig';startClicky(24697137,'fwdb1');</script><noscript><p><img alt="Clicky Web Analytics" src="http://in.freewebs.getclicky.com/24697137-fwdb1.gif"/></p></noscript><script>

_udn="none";

</script><?php

            echo "Games made by ".$user[1];

            echo "<table><tr><th>Name</th><th>Creator</th><th>Description</th><th>Rating</th></tr>";

            $result=mysql_query('SELECT * FROM `games` WHERE `game_creator_num`='.$_GET['id'].' ORDER BY `game_rating` DESC LIMIT '.$base.' , '.$roof) or die("An error has occured. Please refresh the page. error: ".mysql_error());

        } else {

            $b=0;

            echo "The user does not exist";

        }

    }

}

if($b) {

while($ok=mysql_fetch_row($result)) {

    if (strlen($ok[12]) > 100) {

    $desc = substr($ok[12], 0, strrpos(substr($ok[12], 0, 100), ' ')) . '...';

    } else {

    $desc=$ok[12];

    }

    echo "<tr><td><a href='".$_SEVER['php_self']."?page=game.php&game=".$ok[0]."'>".$ok[1]."</a></td><td>".$ok[11]."</td><td>".$desc."</td><td>".$ok[20]."</td></tr><br>";

}

echo "</table>";

}

?>[/code]There is no<tbody> either! could this be because its used in an include?

Link to comment
Share on other sites

@madtechie, the tbody is inserted by the browser automatically, so this is the correct code snippit.

 

@meiamsome the problem is due to this line (but not necessarily limited to it)

 

    echo "<tr><td><a href='".$_SEVER['php_self']."?page=game.php&game=".$ok[0]."'>".$ok[1]."</a></td><td>".$ok[11]."</td><td>".$desc."</td><td>".$ok[20]."</td></tr><br>";

 

See how you have a </tr><br>

 

Because the br is after the closing tr, but inside the table tags, the browser moves the br's up before the table. You might have more lines in your code with this problem, but I spotted this and it's definitely a problem ;)

 

Hope that helps...

Link to comment
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.