PHP MySQL Result displays twice why? -


i have simple php script fetch results localhost wamp server, , when echo query displays 1 record twice every record have!

result displayed shown in picture:

php mysql result displayed twice

here php mysql script

<?php error_reporting(e_all ^ e_deprecated); $movie_lists = ""; $no_result = "";  $servername = "localhost"; $username = "root"; $password = "localpass"; $dbname = "movieadventuredb"; // create connection $conn = new mysqli($servername, $username, $password, $dbname); // check connection if ($conn->connect_error) {     die("connection failed: " . $conn->connect_error); }  //$sql = "select id, movie_quality, movie_release_date movielisting"; $sql = "select * movielisting order id desc limit 10"; $result = $conn->query($sql);  if ($result->num_rows > 0) { // output data of each row    while($row = $result->fetch_assoc()) {        //echo "id: " . $row["id"]. " - name: " . $row["movie_name"]. " " .     $row["movie_quality"]. "<br>";      $id = $row["id"];     $movie_quality = $row["movie_quality"];     $release_date = strftime("%y", strtotime($row["movie_release_date"]));      $movie_lists .= "<div class='item item-1'><a href='#'><img src='inventory_images/$id.jpg'/></a>                         <a href='#'><div class='overlay'>                             <p class='movie_quality $movie_quality'>$movie_quality</p>                             <p class='movie_year year'>$release_date</p>                         </div></a>                     </div>";        }    } else {       $movie_lists = "";    }       $conn->close();  ?> 

below code css listing.

.recent_movies_slider .recent_movie_lists {float:left; width:97%;} .slider-horizontal {width:90%; margin:25px auto; *background:#eee; height:240px; z-index:1;} .slider-horizontal .item {height:200px; width:150px; margin:20px 10px 0;} .slider-horizontal .item img {height:200px; width:150px;} .slider-vertical {width:364px; margin:25px 0; float:left; background:#eee; height:300px;} .slider-vertical .item {height:80px; width:324px; margin:10px 0 10px 20px;} .overlay { position: relative; top:-204px; left:0; *right:0; *bottom:0; width:150px; height:200px; z-index:2; display:block; *background:red; *background-color: rgba(0,0,0,0.5); color:#fff;} .overlay:hover {background:rgba(48, 160, 186, 0.43) url("../default_images/play-button.png") no-repeat; background-position:50% 50%;} .movie_quality { position: absolute; bottom: 5px; left: 5px; text-transform:uppercase;  }    .hd {background:#b43104; padding:2px; border-radius:2px;}    .cam {background:#dba901; padding:2px; border-radius:2px;}    .year {background:#086a87; padding:2px; border-radius:2px;}    .movie_year {       position: absolute;       bottom: 5px;       right: 5px;    } 

and below html echo out result

<div class="recent_movie_lists">    <div id="slider" class="slider-horizontal">        <?php echo $movie_lists; ?>    </div> </div> 

try setting this: $movie_lists = (all code); instead of $movie_lists .= (all code).

sorry stuff above, allready answered in comments. why don't echo out while loop in div?

<div class="recent_movie_lists">    <div id="slider" class="slider-horizontal">        <?php        if ($result->num_rows > 0) { // output data of each row    while($row = $result->fetch_assoc()) {        //echo "id: " . $row["id"]. " - name: " . $row["movie_name"]. " " .     $row["movie_quality"]. "<br>";      $id = $row["id"];     $movie_quality = $row["movie_quality"];     $release_date = strftime("%y", strtotime($row["movie_release_date"]));      echo "<div class='item item-1'><a href='#'><img src='inventory_images/$id.jpg'/></a>                         <a href='#'><div class='overlay'>                             <p class='movie_quality $movie_quality'>$movie_quality</p>                             <p class='movie_year year'>$release_date</p>                         </div></a>                     </div>";        }    } else {       echo "";    } ?>    </div> </div> 

as i'm assuming keeping html , php in same file.


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -