I'm writing a webpage in php to retrieve player details from a mySQL database and writing them to the body in divs, for instance:
<div class="infoDiv">
<img style="margin: 10px; float:left" src="epoch.png>
<p>Player Name: Kez</p>
<p>Player ID: 98723947923749333432</p>
<p>Player Morality: 0</p>
<p>Gender: Male</p>
</div>
What I want to do is put three of these at a time into one div, so that when two more are retrieved from the database it would end the containing div and begin a new one for the next three like so:
<div class="container">
<div class="infoDiv">
<img style="margin: 10px; float:left" src="epoch.png>
<p>Player Name: Kez</p>
<p>Player ID: 98723947923749333432</p>
<p>Player Morality: 0</p>
<p>Gender: Male</p>
</div>
<div class="infoDiv">
<img style="margin: 10px; float:left" src="epoch.png>
<p>Player Name: Kez</p>
<p>Player ID: 98723947923749333432</p>
<p>Player Morality: 0</p>
<p>Gender: Male</p>
</div>
<div class="infoDiv">
<img style="margin: 10px; float:left" src="epoch.png>
<p>Player Name: Kez</p>
<p>Player ID: 98723947923749333432</p>
<p>Player Morality: 0</p>
<p>Gender: Male</p>
</div>
</div>
. The php I'm using to write the data to the document is here:
$con = mysqli_connect($servername, $username, $password, $dbname);
$sql="SELECT PlayerName,PlayerUID,PlayerMorality,PlayerSex FROM player_data";
if ($result=mysqli_query($con,$sql)){
while ($row=mysqli_fetch_row($result)){
echo "<div class=\"infoDiv\">";
echo "<img style=\"margin: 10px; float:left\" src=\"epoch.png\"/>";
echo "<p>Player Name: " . $row[0] . "</p>";
echo "<p>Player ID: " . $row[1] . "</p>";
echo "<p>Player Morality: " . $row[2] . "</p>";
if($row[3]=="0"){
echo "<p>Gender: Male</p>";
}
else{
echo "<p>Gender: Female</p>";
}
echo "</div><br>";
}
mysqli_free_result($result);
}
I apologise in advance for this question, I know it was poorly worded, if you don't understand what I'm asking, feel free to ask. Thanks.