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 8856907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:27:52+00:00 2026-06-14T14:27:52+00:00

This code is working for what I need it to do, but (in my

  • 0

This code is working for what I need it to do, but (in my opinion) it looks bad so I am hoping someone knows of a cleaner or more efficient way to do the same thing. I have several entries being pulled from the database and I want them to be styled identically. Only the logo and the the link name will change eventually I will add a description. Here is the code:

<div class="content">

    <?PHP
        while($row = $stmt->fetch())
        {
            $name = $row['name'];
            $id = $row['id'];
            $logo = $row['logo'];
            $username = $row['username'];
            echo "<div class=" . "Links" . ">";

            echo "<div class=" . "linkImages" . ">";                        
            echo "<br>" . "<a href=" . "Profile.php?id=".$id . ">" . "<img src=" . "users/" . $username . "/images/" . $logo . " " . "width=" . "200" . " " . "height=" . "auto" . " " . "border=" . "0" . "/>" . "</a>";
            echo  "</div>";

            echo "<div class=" . "linkName" . ">";
            echo "<a href=" ."Profile.php?id=".$id .">" . $name ."</a>";
            echo "</div>";

            echo "</div>";

        }
    ?>

</div>
  • 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-14T14:27:53+00:00Added an answer on June 14, 2026 at 2:27 pm

    You can trivially remove most of the echoes and string concatenation by switching to a HEREDOC:

    while($row = $stmt->fetch()) {
       echo <<<EOL
    <div class="links">
    yadayada
    <br><a href="Profile.php?id={$row['id']}"><img src="users/{$row['username']}" etc....
    yada yada yada
    EOL;
    

    Note that the lack of escapes in there, allowing for proper quotes around the tag attributes, and the {} notation on the embedded variables.

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

Sidebar

Related Questions

I have this working code, but now i need to be able to change
This code is working but there must be a better way to do this
I have this JQuery code working however I need to know whether how to
I tried everything to get this code working, and I hope someone will save
this seems to be weird but it really happened. I have this code working
This code is working on other test environment but not on mine. Do you
I have this code and its working fine with PHP 5.3 onwards but i
I'm testing ExtJS4, but need some help here... I have this HTML code: <input
I need to know how to get this code working on Django. This example
i am using this code and working fine but the problem with this code

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.