Inserting multiple records in different php placeholders and mesh system errors

I am developing a website to display different coupons and the data is taken from a database. It has 4 columns containing ID, name, no coupons, signature as shown here Image is shown below.

Now the basic idea is to create a specialized store section in the php page that contains an image that takes the storename.jpeg file as the source to get the image. It also has a div that doesn't have coupons or labels. How do I write a query to individually access these 3 columns? In addition, the grid does not work correctly on small devices, some of them are not in the correct position. Below is the code snippet

$( document ).ready(function() {
    $("[rel='tooltip']").tooltip();    
 
    $('.thumbnail').hover(
        function(){
            $(this).find('.caption').slideDown(250); //.fadeIn(250)
        },
        function(){
            $(this).find('.caption').slideUp(250); //.fadeOut(205)
        }
    ); 
});
      

body {
  padding-top: 50px;
}
 
.thumbnail {
    position:relative;  
    overflow:hidden;
}
 
.caption {
    position:absolute;
    top:0;
    right:0;
    background:rgba(66, 139, 202, 0.75);
    width:100%;
    height:100%;
    padding:2%;
    display: none;
    text-align:center;
    color:#fff !important;
    z-index:2;
}
      

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<?php
//Step1
 $db = mysql_connect("localhost","root","sai123"); 
 if (!$db) {
 die("Database connection failed miserably: " . mysql_error());
 }
//Step2
 $db_select = mysql_select_db("AskCoupon.com",$db);
 if (!$db_select) {
 die("Database selection also failed miserably: " . mysql_error());
 }
 // echo "Database connection Established";
?>
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Promotional codes,Coupons,Deals and many more</title>

   <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet">
        
   
  </head>
  <body>
  <?php $query = "select * from featured_stores"; $result = mysql_query($query);?>
  <?php if (!$result) die ("Database access failed: " . mysql_error());?>
  
  
<div class="container">
  
    <div class="row">
        <div class="col-lg-2 col-sm-6 col-xs-6 col-md-3">            
            <div class="thumbnail">
                <div class="caption">
                    <h4>Placeholder Coupon no</h4>
                    <p>Get exiting deals here</p>
                    
                </div>
                <img src="img/flipkart.jpeg" alt="...">
            </div>
      </div>
      
        <div class="col-lg-2 col-sm-6 col-xs-6 col-md-3">            
            <div class="thumbnail">
                <div class="caption">
                    <h4>Placeholder Coupon no</h4>
                    <p>Get exiting deals here</p>
                    
                </div>
                <img src="img/paytm.jpeg" alt="...">
            </div>
      </div>

        <div class="col-lg-2 col-sm-6 col-xs-6 col-md-3">            
            <div class="thumbnail">
                <div class="caption">
                    <h4>Placeholder Coupon no</h4>
                    <p>Get exiting deals here</p>
                    
                </div>
                <img src="img/savaari.jpeg" alt="...">
            </div>
      </div>

        <div class="col-lg-2 col-sm-6 col-xs-6 col-md-3">            
            <div class="thumbnail">
                <div class="caption">
                    <h4>Placeholder Coupon no</h4>
                    <p>Get exiting deals here</p>
                    
                </div>
                <img src="img/uber.jpeg" alt="...">
            </div>
      </div>

      <div class="col-lg-2 col-sm-6 col-xs-6 col-md-3">            
            <div class="thumbnail">
                <div class="caption">
                    <h4>Placeholder Coupon no</h4>
                    <p>Get exiting deals here</p>
                    
                </div>
                <img src="img/foodpanda.jpeg" alt="...">
            </div>
      </div> 
      <div class="col-lg-2 col-sm-6 col-xs-6 col-md-3">            
            <div class="thumbnail">
                <div class="caption">
                    <h4>Placeholder Coupon no</h4>
                    <p>Get exiting deals here</p>
                    
                </div>
                <img src="img/mobikwik.jpeg" alt="...">
            </div>
      </div>       
        
  </div>






  <div class="row">
        <div class="col-lg-2 col-sm-6 col-xs-6 col-md-3">            
            <div class="thumbnail">
                <div class="caption">
                    <h4>Placeholder Coupon no</h4>
                    <p>Get exiting deals here</p>
                    
                </div>
                <img src="img/zoomcar.jpeg" alt="...">
            </div>
      </div>
      
        <div class="col-lg-2 col-sm-6 col-xs-6 col-md-3">            
            <div class="thumbnail">
                <div class="caption">
                    <h4>Placeholder Coupon no</h4>
                    <p>Get exiting deals here</p>
                    
                </div>
                <img src="img/jabong.jpeg" alt="...">
            </div>
      </div>

        <div class="col-lg-2 col-sm-6 col-xs-6 col-md-3">            
            <div class="thumbnail">
                <div class="caption">
                    <h4>Placeholder Coupon no</h4>
                    <p>Get exiting deals here</p>
                    
                </div>
                <img src="img/tinyowl.jpeg" alt="...">
            </div>
      </div>

        <div class="col-lg-2 col-sm-6 col-xs-6 col-md-3">            
            <div class="thumbnail">
                <div class="caption">
                    <h4>Placeholder Coupon no</h4>
                    <p>Get exiting deals here</p>
                    
                </div>
                <img src="img/americanswan.jpeg" alt="...">
            </div>
      </div>
      <div class="col-lg-2 col-sm-6 col-xs-6 col-md-3">            
            <div class="thumbnail">
                <div class="caption">
                    <h4>Placeholder Coupon no</h4>
                    <p>Get exiting deals here</p>
                    
                </div>
                <img src="img/snapdeal.jpeg" alt="...">
            </div>
      </div>      
      <div class="col-lg-2 col-sm-6 col-xs-6 col-md-3">            
            <div class="thumbnail">
                <div class="caption">
                    <h4>Placeholder Coupon no</h4>
                    <p>Get exiting deals here</p>
                    
                </div>
                <img src="img/askmebazaar.jpeg" alt="...">
            </div>
      </div>  
        
  </div>
  
</div><!-- /.container -->

    
  </body>
</html>
      

Run code


From the code that the coupon should not be fetched from the database and stored in the name placeholder-coupon-no and the image src from store_name and the p tag in the header div to be replaced with the header from the database.

+3


source to share


2 answers


You just need to iterate over the results of your query. You can use the following for your reference.



<?php 
    $query = "select * from featured_stores"; 
    $result = mysql_query($query)
    if (!$result) die ("Database access failed: " . mysql_error());
?>

<div class="container">
    <div class="row">

    <?php while($row=mysql_fetch_array($result)): ?>

        <div class="col-lg-2 col-sm-6 col-xs-6 col-md-3">            
            <div class="thumbnail">
                <div class="caption">
                    <h4><?=  $row['no_of_coupons']; ?></h4>
                    <p><?= $row['caption']; ?></p>
                </div>
                <img src="img/" .<?= $row['store_name']; ?> . ".jpeg" alt="...">
            </div>
        </div>

    <?php endwhile; ?>

    </div>
</div>

      

0


source




<?php require_once("includes/database.php");?>
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Ask Coupon | Promotional codes,Coupons,Deals and many more</title>
<link rel="stylesheet" href="css/hover.css">
   <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet">
   <!-- jQuery (necessary for Bootstrap JavaScript plugins) -->

    <script src="jquery/jquery-2.1.4.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="js/bootstrap.min.js"></script>
     <script>
    $( document ).ready(function() {
    $("[rel='tooltip']").tooltip();    
 
    $('.thumbnail').hover(
        function(){
            $(this).find('.caption').slideDown(250); //.fadeIn(250)
        },
        function(){
            $(this).find('.caption').slideUp(250); //.fadeOut(205)
        }
    ); 
});
</script> 
   
  </head>
  <body>
  <?php $query = "select store_name,no_of_coupons,caption from featured_stores";
   $result = mysql_query($query);?>
  <?php if (!$result) die ("Database access failed: " . mysql_error());?>
  
  
<div class="container">
  
    <div class="row">
    <?php
    while($row = mysql_fetch_assoc($result)) {?>
        
    
        <div class="col-lg-2 col-sm-6 col-xs-6 col-md-3">            
            <div class="thumbnail">
                <div class="caption">
                    <h4><?php echo $row["no_of_coupons"]?></h4>
                    <p><?php echo $row["caption"]?></p>
                    
                </div>
                <img src="img/<?php echo $row["store_name"]?>.jpeg" alt="...">
            </div>
      </div>
      <?php
      }?>
      
  </div>
  
</div><!-- /.container --> 




    
  <?php
require_once("includes/database_closing.php"); ?>
    
  </body>
</html>
      

Run code


0


source







All Articles