Im wondering if its possible with PHP to add a class to X record returned. I know I can do this with JS only I’d like it to have the class added as the records are returned.
I have the following loop in my PHP, From what I’ve found in google I need to add a counter to do this only I’ve been unsuccessful so far…
while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
echo '<div class="entry span3"><span class="name">' . $row['First_Name'] . ' ' . $row['Surname'] . "</span>";
echo '<img src="' . $row["picture_1"] . '" alt="' . $row['First_Name'] . ' ' . $row['Surname'] . ', text ' . $row['Date'] . ' ">';
echo '<span class="from">seen in ' . ucwords($row["Location_County__Seen"]) . '</span><a href="/' . strtolower($row["Surname"]) . '/' . $row["ID"] . '">View Profile</a></div>';
}
In front of your while, add
$c = 1Before the end of your while loop, add
$c++;Then, modify your first line:
echo '<div class="entry span3"><span class="name">'To
For the final result: