I have a MySQL DB "dorav3"
with a table "dtab1"
with the below column containing business card info. I also have a php script and HTML page to display the DB data in a HTML table.
My question is how can I go from just populating a table to populating my flip cards below
where I currently do <td><?php echo $row1[0];?></td>
for the table
Should I do something like for the flip card?
<body>
<div class="flip-box">
<div class="flip-box-inner">
<div class="flip-box-front">
<h2><?php echo $row1[0];?></h2>
<h2><?php echo $row1[1];?></h2>
</div>
<div class="flip-box-back">
<h4><?php echo $row1[2];?></h4>
<h4><?php echo $row1[3];?></h4>
<h4><?php echo $row1[4];?></h4>
</div>
</div>
</div>
I am really stuck!
+--------------------+---------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------------------+---------+------+-----+---------+----------------+
| Title | text | YES | | NULL | |
| Name | text | YES | | NULL | |
| Email | text | YES | | NULL | |
| Website | text | YES | | NULL | |
| Contact | text | YES | | NULL | |
| id | int(11) | NO | PRI | NULL | auto_increment |
----------------------------------------------------------------------
PHP
<?php
// php populate html table from mysql database
$hostname = "localhost";
$username = "xxx";
$password = "xxx";
$databaseName = "dorav3";
// connect to mysql
$connect = mysqli_connect($hostname, $username, $password, $databaseName);
// mysql select query
$query = "SELECT * FROM `dtab1";
// result for method one
$result1 = mysqli_query($connect, $query);
// result for method two
$result2 = mysqli_query($connect, $query);
$dataRow = "";
while($row2 = mysqli_fetch_array($result2))
{
$dataRow = $dataRow."<td>$row2[0]</td><td>$row2[1]</td><td>$row2[2]</td><td>$row2[3]</td><td>$row2[4]</td><td>$row2[5]</td><td>$row2[6]</td><td>$row2[7]</td><td>$row2[8]</td><td>$row2[9]</td><td>$row2[10]</td><td>$row2[11]</td><td>$row2[12]</td><td>$row2[13]</td><td>$row2[14]</td><td>$row2[15]</td>";
}
?>
HTML to Populate table
<body>
<table>
<tr>
<th>Title</th>
<th>Name</th>
<th>Email</th>
<th>Website</th>
<th>Contact</th>
</tr>
</table>
<?php while($row1 = mysqli_fetch_array($result1)):;?>
<table>
<tr>
<td><?php echo $row1[0];?></td>
<td><?php echo $row1[1];?></td>
<td><?php echo $row1[2];?></td>
<td><?php echo $row1[3];?></td>
<td><?php echo $row1[4];?></td>
</tr>
</table>
<?php endwhile;?>
</body>
</html>
What I want to do next is populate a more rich format with my data.
HTML to Populate cards
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<div class="flip-box">
<div class="flip-box-inner">
<div class="flip-box-front">
<h2>Title</h2>
<h2>Name</h2>
</div>
<div class="flip-box-back">
<h4>Email</h4>
<h4>Website</h4>
<h4>Contact</h4>
</div>
</div>
</div>
<div class="flip-box">
<div class="flip-box-inner">
<div class="flip-box-front">
<h2>Title</h2>
<h2>Name</h2>
</div>
<div class="flip-box-back">
<h4>Email</h4>
<h4>Website</h4>
<h4>Contact</h4>
</div>
</div>
</div>
<div class="flip-box">
<div class="flip-box-inner">
<div class="flip-box-front">
<h2>Title</h2>
<h2>Name</h2>
</div>
<div class="flip-box-back">
<h4>Email</h4>
<h4>Website</h4>
<h4>Contact</h4>
</div>
</div>
</div>
</div>
</body>
</html>