Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6830199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:35:23+00:00 2026-05-26T22:35:23+00:00

When I launch my web page, increment doesn’t work correctly! It should go like

  • 0

When I launch my web page, increment doesn’t work correctly!

It should go like this: $i = from 1 to x (0,1,2,3,4,5,6 etc..).
But instead it jumps over every step giving result of (1,3,5,7 etc..).

Why is this code doing this?

<ul class="about">
        <?php
            $result = mysql_query("SELECT * FROM info WHERE id = 1");

            while ($row = mysql_fetch_assoc($result))
            {
                $bioText = $row['bio'];
            }

            $endBioTxt = explode("\n", $bioText);

            for ($i=0; $i < count($endBioTxt);)
            {
                if (checkNum($i) == true)
                {
                    echo "<li class='left'><div>".$endBioTxt[$i]."</div></li>";
                    echo $i;
                }
                else
                {
                    echo "<li class='right'><div>".$endBioTxt[$i]."</div></li>";
                    echo $i;
                }
                $i++;
            }


            // Function to check if number is prime
            function checkNum($num){
              return ($num % 2) ? TRUE : FALSE;
            }

        ?>
    </ul>

Output:

Sometext!(right side)
0
1
Sometext2!(right side)
2
3
…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:35:24+00:00Added an answer on May 26, 2026 at 10:35 pm

    This code works, please test it in your environment and then uncomment/comment what you need.

    <?php
    
    // This is how query should look like, not big fan of PHP but as far as I remember...
    /*
    $result = mysql_query("SELECT * FROM info WHERE id = 1");
    $row = mysql_fetch_assoc($result);
    
    $bioText = $row['bio'];
    $endBioTxt = explode("\n", $bioText);
    */
    
    $endBioTxt[0] = "one";
    $endBioTxt[1] = "two";
    $endBioTxt[2] = "three";
    $endBioTxt[3] = "four";
    $endBioTxt[4] = "five";
    
    $totalElements = count($endBioTxt);
    
    for ($i = 0; $i < $totalElements; $i++)
    {
        if ($i % 2)
        {
            echo "<li class='left'><div>".$endBioTxt[$i]."</div></li>";
        }
        else
        {
            echo "<li class='right'><div>".$endBioTxt[$i]."</div></li>";
        }
    
        /*
        // This is how you should test if all your array elements are set
        if (isset($endBioTxt[$i]) == false)
        {
            echo "Array has some values that are not set...";
        }
        */
    }
    

    Edit 1

    Try using $endBioTxt = preg_split('/$\R?^/m', $bioTxt); instead of explode.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to launch iPhone Camera from web page. I googled around and came
For years I've been using ShellExecute() API to launch the default web browser from
I am trying to open a web page with a Silverlight App from a
I'm trying to publish my app with ClickOnce to install from a Web page.
I have a web page driven by data taken from an Exchange server using
What I'd like to do is provide a link on an intranet web page
In my web application I would like to make a response-test process. This process
I use the below code to launch a web page in default system browser:
I am trying to launch the nunit gui app from an asp.net mvc web
I know this will seem like a dumb question but I'm just getting started

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.