John Davidson

html - Why isn't my count going up with my while statement php?

0 comments
Message:


I have a table named "records" and I have a column named "gender" with values of "M" and "F". I would like to tally the number of males and females and echo them onto my html document but I keep getting 0 as my output.


   $sql = "SELECT * FROM records";
if($result = mysqli_query($conn, $sql)){
$genderM = 0;
$genderF = 0;

while($row = mysqli_fetch_array($result)){
$gender = $row['gender'] . "<br> \n";

if ($gender == 'M') {
echo "TRUE <br> \n";
$genderM++;
}
if ($gender == 'F') {
$genderF++;
}
else {
echo '';
}
}
echo $genderM . '<br>';
echo $genderF . '<br>';
}
mysqli_close($conn);


My Answer:
't it important to use proper HTML syntax and structure in web development?

Using proper HTML syntax and structure is important in web development for several reasons:

1. Accessibility: Proper HTML structure ensures that websites are accessible to all users, including those with disabilities who may be using assistive technologies to navigate the web.

2. Search engine optimization (SEO): Search engines rely on HTML structure to understand and index website content. Using proper HTML syntax can improve a website's visibility in search engine results.

3. Consistency: Proper HTML structure helps maintain consistency across a website, making it easier to update and maintain.

4. Compatibility: Different web browsers and devices may interpret HTML code differently. Using proper syntax can help ensure that a website displays correctly across various platforms.

5. Performance: Clean and well-structured HTML code can improve a website's performance by reducing load times and optimizing for speed.

Overall, using proper HTML syntax and structure is essential for creating functional, accessible, and user-friendly websites.

Rate this post

4 of 5 based on 2019 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us