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

  • SEARCH
  • Home
  • 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 8775037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:42:39+00:00 2026-06-13T18:42:39+00:00

I’m trying to loop this code, so that when the while statement on the

  • 0

I’m trying to loop this code, so that when the while statement on the php code start the database output will have an individual <li> per output

    <li class="bar<?php echo $id; ?>">
    <div align="left" class="post_box">
    <span style="padding:10px"><?php echo $msg; ?> </span>
    <span class="delete_button"><a href="#" id="<?php echo $id; ?>" class="delete_update">X</a></span>
    <span class='feed_link'><a href="#" class="comment" id="<?php echo $id; ?>">comment</a></span>
    </div>
    <div id='expand_box'>
    <div id='expand_url'></div>
    </div>
    <div id="fullbox" class="fullbox<?php echo $id; ?>">
    <div id="commentload<?php echo $id; ?>" >
    </li>

this is my php code

    </div>
    <div class="comment_box" id="c<?php echo $id; ?>">
    <form method="post" action="" name="<?php echo $id; ?>">
    <textarea class="text_area" name="comment_value" id="textarea<?php echo $id; ?>">
    </textarea><br />
    <input type="submit" value=" Comment " class="comment_submit" id="<?php echo $id; ?>"/>
    </form>
    </div>
    </div>

<?php
if($_POST['submit'] == "submit"){
   $username="xxx_admin";
   $password="xxx";
   $database="xxx_database";

//connect to mysql server
                $mysqli = new mysqli("localhost", $username, $password, $database);

                                        //check if any connection error was encountered
                                        if(mysqli_connect_errno()) {
                                            printf("Connect failed: %s\n", mysqli_connect_error());
                                            exit;
                                        }   
   $client_id = $_POST['client_id'];
   echo $client_id;
  $query="select * from messages where client_id='$client_id'";
  $result = $mysqli->query( $query );
  $row = $result->fetch_assoc();
                                        while ($row = $result->fetch_object())
                                        {
                                                // set up a row for each record
                                                echo "<li>";
                                                $mes = $row->message;
                                                $mes = nl2br($mes);

                                                $msg ="{$mes} <br> . {$row->date_post;}";

?>
<li class="bar<?php echo $id; ?>">
<div align="left" class="post_box">
<span style="padding:10px"><?php echo $msg; ?> </span>
<span class="delete_button"><a href="#" id="<?php echo $id; ?>" class="delete_update">X</a></span>
<span class='feed_link'><a href="#" class="comment" id="<?php echo $id; ?>">comment</a></span>
</div>
<div id='expand_box'>
<div id='expand_url'></div>
</div>
<div id="fullbox" class="fullbox<?php echo $id; ?>">
<div id="commentload<?php echo $id; ?>" >

</div>
<div class="comment_box" id="c<?php echo $id; ?>">
<form method="post" action="" name="<?php echo $id; ?>">
<textarea class="text_area" name="comment_value" id="textarea<?php echo $id; ?>">
</textarea><br />
<input type="submit" value=" Comment " class="comment_submit" id="<?php echo $id; ?>"/>
</form>
</div>
</div>
</li>
<?php                                   }

     $mysqli->close();
}
?>

I’m trying to loop the html code because it will be put inside an <ol></ol>

all rows in the database should have an individual <li></li>

  • 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-06-13T18:42:40+00:00Added an answer on June 13, 2026 at 6:42 pm

    In the official PHP site exists same examples of loops.

    <?php
    $arr = array("one", "two", "three");
    reset($arr);
    while (list(, $value) = each($arr)) {
        echo "Value: $value<br />\n";
    }
    
    foreach ($arr as $value) {
        echo "Value: $value<br />\n";
    }
    ?> 
    

    you should, instead of firstly render the html, load the messages into a array, and after this, iterate this array doing the html renderization

    good luck!

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm trying to create an if statement in PHP that prevents a single post
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I am trying to loop through a bunch of documents I have to put
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into
This could be a duplicate question, but I have no idea what search terms

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.