How to print all the values in a single css cards..?

I was retreiving the data based on the particular input and trying to print that data using css cards instead of table…But for each value its printing in a new card instead using a the same card to print the value…

Below is HTML

          <form method="post">
         <div  class="wrapper">
         <label for="dropdown">Inverter</label>
         <select name="options" id="dropdown" class="selectpicker">
         <option>Select The Inverter</option>
         <option value="1">Inverter 1</option>
         <option value="2">Inverter 2</option>
         <option value="3">Inverter 3</option>
         <option value="4">Inverter 4</option>
         <option value="5">Inverter 5</option> 
         <option value="6">Inverter 6</option>
         </select>
         
         <input type="submit" class="btn btn-default" name="submit"> 

Below is my PHP code

          <?php 
      if(isset($_POST["options"],$_POST["submit"]))
     {
	  $inverter = $_POST["options"];
	  $query = "select * from inverterlog where inverter = '" . $inverter . "'";
	  $execute = mysqli_query($con,$query);
	  if($execute !== FALSE && mysqli_num_rows($execute)> 0)
	  {
        while($row = mysqli_fetch_array($execute))
		{
			$timestamp = $row['timestamp'];
      ?>
		
      <!--card-->
     <div class="card">
    <img src="img_avatar2.png" alt="Avatar" style="width:100%">
     <div class="container">
     <h5><b>TimeStamp</b></h4>
     <p><?php echo "$timestamp"?></p>	
     </div>
     </div>
  <?php 
         		}
	  }
           else
	           {
		    echo 'alert("Data does not exist....")';
		   }
           }	
     ?>

Below is the link how it looks like…

https://ibb.co/npqLi5

I don’t really (well, at all) know what CSS “cards” are, and your link doesn’t bring anything up.

Inside your loop, you open a div of class card, and then another of class container - is that what you intended? Should you open one or both of those outside the loop, and then just loop through the values, then close one or both divs?

@droopsnoot…first div class .i.e div class=“card” contains image and second div class contains the data…css is not linked to this…each time value is fetched its printed in new card …instead I want all the values to be printed on the single card… I’ve doat in my php code…please go tru my php code and notify the mistake ive done…

In that case, I think you need to move the opening divs to before the start of the while() loop, and move the div closing tags to after the end of that loop.

2 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.