Jump to content

Displaying array is messing with html


wee493

Recommended Posts

I have an array that I'm trying to display from an sql db. The array is displaying fine, but it messes with the html code.

<?
$user = $session->username;
$sql = "SELECT * FROM `url` WHERE `user`='$user' ORDER BY  `url`.`id` ASC";
$result = mysql_query($sql);

if(mysql_num_rows($result) == '0') {
	echo "<font color='#000'>You have not created any URL's yet. You can do so from the home screen.</font>";
}
while($row = mysql_fetch_array($result) or die(mysql_error())) {
	$url = stripslashes($row[url]);
	$dest = stripslashes($row[destination]);

echo "<tr bgcolor='#fff'>
<td width='200' valign='bottom'>
<a href=\"http:\//wiurl.com/$url\">http://wiurl.com/$url</a></td>
<td width='200' align='left' valign='bottom'><br>$dest</tr>";
}

?>

If i put the closing } from the while  command at the very end of the page some of the html is repeated, but if i put it where it is displayed currently the page does not display the html after the php code.

 

you can see the messed up page here http://wiurl.net/myurls.php

 

If you want to see the entire page i have attached it below,

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>WiURL - Make any URL a Wi one</title>
<link rel="stylesheet" type="text/css" href="style.css" media="screen" />
</head>
<body>
<table border="0" align="center">
<tr>
<td height="10" bordercolor="#CCCCCC"> </td>

</tr>
<tr>
<td>
<div id="wrapper">

<div id="header">
<div id="logo">
	<h1><a href="#">WiURL</a></h1>
	<p>Make any URL a Wi one</p>
</div>

<!-- end #logo -->
<div id="menu">
	<ul>
		<li class="active"><a href="http://wiurl.com">Home</a></li>
		<li class="active2"><a href="total.php">Top URL's</a></li>
		<li class="active2"><a href="download.htm">Download</a></li>
		<li class="active2"><a href="templates/construction.htm">Support</a></li>
	</ul>
</div>
<!-- end #menu -->
</div>
<!-- end #header -->
<div id="page">
<div id="content">
	<div class="post">
		<h1 class="title">Create a WiURL</h1>
<table border="0" bgcolor="#FFFFFF" width="400">
<?
$user = $session->username;
$sql = "SELECT * FROM `url` WHERE `user`='$user' ORDER BY  `url`.`id` ASC";
$result = mysql_query($sql);

if(mysql_num_rows($result) == '0') {
	echo "<font color='#000'>You have not created any URL's yet. You can do so from the home screen.</font>";
}
while($row = mysql_fetch_array($result) or die(mysql_error())) {
	$url = stripslashes($row[url]);
	$dest = stripslashes($row[destination]);

echo "<tr bgcolor='#fff'>
<td width='200' valign='bottom'>
<a href=\"http:\//wiurl.com/$url\">http://wiurl.com/$url</a></td>
<td width='200' align='left' valign='bottom'><br>$dest</tr>";
}

?>
</table>
            </div>

          <br /><br /></div>
<!-- end #content -->
<div id="sidebar">
	<div id="sidebar-bgtop"></div>
	<div id="sidebar-content">
		<div id="sidebar-bgbtm">
		<ul>
			<? include("sidebar.php"); ?>
		</ul>
	</div>
	</div>
</div>
<!-- end #sidebar -->
</div>
<!-- end #page -->

</div>

<div id="footer">
<p>© 2009. Base Design by <a href="http://www.freecsstemplates.org/">Free CSS Templates</a>. Other Modifications by <u>Wee493</u></p>
</div>
</td></tr></table>
<!-- end #footer -->
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/160432-displaying-array-is-messing-with-html/
Share on other sites

Change you while to:

while($row = mysql_fetch_array($result)) {
      $url = stripslashes($row[url]);
      $dest = stripslashes($row[destination]);

echo "<tr bgcolor='#fff'>
<td width='200' valign='bottom'>
<a href=\"http:\//wiurl.com/$url\">http://wiurl.com/$url</a></td>
<td width='200' align='left' valign='bottom'><br>$dest</tr>";
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.