Im having a problem incrementing a counter in one of my while loops basically i just want to alternate between two image links that were fetched in my database but my counter wo
Initialize $i outside the loop.
$i = 0;
while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$img_link = $row['Image'];
$img_link_alt = $row['Image_alt'];
echo '';
$img = ( $i % 2 == 0 ) ? $img_link : $img_link_alt;
echo $i;
//'?' . date("h:i:sa").'
echo '';
echo 'Screenshot
Updated Screenshot of the Botting session: ' . $row['script_name'] .' ';
echo '';
$i++;
}