I have problem adding php in website

This what i want http://slimhamdi.net/lina/demos/blog-post-dark.html
like this page.Problem is images not on right place also hr spouse to be longer and smaller.I tried too many to do it by self no luck.

<?php 

 $servername = "localhost";
 $username = "root";
 $password = "";

} 

$count = 0;
$images = array("user1.jpg", "user2.jpg", "user3.jpg"); // 

if( $result->num_rows > 0 ) {
    // output data of each row
    while( $row = $result->fetch_assoc() ) {
        
                echo '<div id="mydiv4" style="margin-top:-1310px;padding-bottom:1px;  "';                 
			   echo '<div class="comment-block">
						
                    '.( !empty( $images[$count] ) ? '<img  src="images/blog/'.$images[$count].'">' : '').' <!-- Add the count to the images to use it as a key, add check to see if count is a key -->
                    <span class="name">'.$row['name'].'</span>
                    <span class="comment">'.$row['comment'].'</span>
                 </div>
             </div>
			 </div>
			 </div>
			'; 

        $count++; // this usually goes at the end of a loop don't know if this produces the result you want
        if( $count == 3 )
        {
          $count = 0; // Reset to 0 if 3 images have been shown
        }
    } 
}
 
?> 

Any help will be appricate

What the O.P really wants is help to create a blog as may be seen in this thread…

https://www.sitepoint.com/community/t/i-need-two-different-size-echo-hr/304712

We finally managed to get the O.P. to supply the files that they were using.

These may be be seen, in their corrected and validated state, in the attachment here…

https://www.sitepoint.com/community/t/i-need-two-different-size-echo-hr/304712/31?u=coothead

Good luck. :biggrin:

coothead

As we have said repeatedly, those issues are CSS issues, not PHP. Both have been solved by @coothead in his corrected version of your files.

If you need help producing the PHP which will output the required HTML structure, then you need to ask for that help, and not keep repeating questions which are not PHP and have already been answered.

If there is something about coothead’s code which you do not understand, then ask for clarification in the relevant thread. Please don’t start multiple threads for the same questions.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.