Mysqli getting unwanted duplicates displayed :(

Codes here !

Moderators: egami, macek, gesf

Post Reply
jmd87
New php-forum User
New php-forum User
Posts: 4
Joined: Thu Oct 26, 2017 9:47 am

Thu Oct 26, 2017 9:55 am

Hi,

Can anyone help please. I am getting unwanted duplicates displayed in my script and the more records I add the more duplicates it has. There are no duplicate records in the MYSQLi database and am a little confused to why this is happening and how to go about solving it can anyone help please? :)

Code: Select all

<?php 
//Include Database Connection File from Includes/Config
include 'includes/config/db.inc.php';

//Select Database and Tables
$sql = "SELECT * FROM dow_list_01, dow_settings, dow_page_content ORDER BY dow_list_sort_order";
$result = $conn->query($sql);
?>
<!doctype html>
<?php
//Load Data from Database
if($result->num_rows > 0) {
	while($row = $result->fetch_assoc()){
		?>
<html>
<head>
<meta charset="utf-8">
<title><?php echo $row['dow_website_title']; ?> - <?php echo $row['dow_title']; ?></title>
<meta name="robot" content="<?php echo $row['dow_meta_robot']; ?>">
<meta name="description" content="<?php echo $row['dow_meta_description']; ?>">
<meta name="keywords" content="<?php echo $row['dow_meta_keywords']; ?>">
<link href="includes/css/frontendmenutop.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="includes/picker/js/jquery.colorpicker.js"></script>
<script type="text/javascript" src="includes/picker/js/jquery.classygradient.js"></script>
<style>
	body {
		 <?php echo $row['dow_background']; ?>
	}
	.page_banner {
		height: <?php echo $row['dow_banner_height']; ?>;
	}
	.page_menu {
		background:<?php echo $row['dow_nav_bar_color']; ?>
	}
	.page_menu a {
		color: <?php echo $row['dow_nav_font_color']; ?>;
		font-family: <?php echo $row['dow_nav_font']; ?>
	}
	.page_menu li {
		background:<?php echo $row['dow_nav_bar_color']; ?>
	}
	.page_menu li:hover {
		background:<?php echo $row['dow_nav_hover_color']; ?>
	}
	.page_container {
		<?php echo $row['dow_body']; ?>
	}
	.list_item{
		<?php echo $row['dow_list_hide']; ?>
	}
	
</style>
</head>

<body>
	<div class="page_container">
		<div class="page_banner"><img src="images/upload/webdesign/banner/<?php echo $row['dow_banner']; ?>"></div>	
		

		<div style="clear: both"></div>
<!doctype html>
<?php
//Load Data from Database
if($result->num_rows > 0) {
	while($list = $result->fetch_assoc()){
		?>
		<div class="list_item">
		<div style="float:left; width:260px"><a href="list_content01.php?id=<?php echo $list['dow_list_id']; ?>"><img src="images/upload/list01/<?php echo $list['dow_list_image_folder']; ?>/000.jpg" style="width:260px; height:152px"></a></div>
			<div style="float:left; width:660px; height:152px; max-height: 152px; overflow: hidden; padding-left:10px"><?php echo $list['dow_list_description']; ?></div>
		</div><div style="clear: both"></div>
			<?php
	}
}
else
{
	?>
	<div>No Page Content Found</div>
	<?php
}
	?>
	</div>

	
			<?php
	}
}
else
{
	?>
	<div>No Page Content Found</div>
	<?php
}
	?>
		</body>
</html>
Thanks alot for any help in advance!

Kind Regards
Joe

User avatar
hyper
php-forum Fan User
php-forum Fan User
Posts: 693
Joined: Mon Feb 22, 2016 5:52 pm

Sat Oct 28, 2017 2:32 am

Duplicates?

While you haven't explained what is duplicated, I suspect this line (and what follows it) has a lot to do with it:

Code: Select all

if($result->num_rows > 0) {
	while($row = $result->fetch_assoc()){
But I haven't examined it in any great detail.

I think that what will help you most is:

Remove styling from this and put it in a css file on its own.
Put your html header in a separate include file.
Format what remains and then you will probably see where the problem is.

Post Reply