meiamsome Posted March 21, 2009 Share Posted March 21, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/150514-solved-extra-tags/ Share on other sites More sharing options...
MadTechie Posted March 21, 2009 Share Posted March 21, 2009 if your refering to the bold <br> Our Games<br><br><br><table><tbody> then your need to post the correct code.. the code posted doesn't even have the <tbody> and as the break are before that, it would seam you need to check earlier code! Quote Link to comment https://forums.phpfreaks.com/topic/150514-solved-extra-tags/#findComment-790585 Share on other sites More sharing options...
meiamsome Posted March 21, 2009 Author Share Posted March 21, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/150514-solved-extra-tags/#findComment-790587 Share on other sites More sharing options...
Floydian Posted March 21, 2009 Share Posted March 21, 2009 @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... Quote Link to comment https://forums.phpfreaks.com/topic/150514-solved-extra-tags/#findComment-790588 Share on other sites More sharing options...
meiamsome Posted March 21, 2009 Author Share Posted March 21, 2009 that was indeed the problem. Thankyou! Quote Link to comment https://forums.phpfreaks.com/topic/150514-solved-extra-tags/#findComment-790589 Share on other sites More sharing options...
Floydian Posted March 21, 2009 Share Posted March 21, 2009 sure thing Quote Link to comment https://forums.phpfreaks.com/topic/150514-solved-extra-tags/#findComment-790592 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.