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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:48:56+00:00 2026-06-06T05:48:56+00:00

I’m a complete newbie when it comes to HTML, I’ve never needed to do

  • 0

I’m a complete newbie when it comes to HTML, I’ve never needed to do any webpage stuff before so apologies if I’m being a simpleton.

I have a high score table for an iOS app, and I want to display it on the website for the app as well. The leaderboard is working fine in the app using PHP and mySQL, but when I try to access the database using PHP inside an HTML file it doesn’t seem to pay any attention to the logic of the PHP (i.e. if I have an if/else statement, it will run both even cases).

Here is a simplified version of my code, if connection to the database is successful then the first column in the table header will say “success”, otherwise it will say “failure”.

<body>

<table class="altrowstable" id="alternatecolor">

<?php
if (!mysql_connect($db_host, $db_user, $db_pwd))
{
    <tr>
    <th>Failure</th><th>Player</th><th>Points</th><th>Played</th><th>Wins</th><th>Draws</th><th>Losses</th>
    </tr>
}
else
{
    <tr>
    <th>Success</th><th>Player</th><th>Points</th><th>Played</th><th>Wins</th><th>Draws</th><th>Losses</th>
    </tr>
}

?>

</table>
</body>

Can anyone see what has been done incorrectly here? I assumed that the if/else would work as normal, but instead I get both rows inserted into the table, “failure” and “success”.

Edit:
I have also tried using echo “”; etc, but not sure which way is correct as they both give me the same error where it ignores the PHP.

  • 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-06T05:48:58+00:00Added an answer on June 6, 2026 at 5:48 am

    Check extension of your file. It need to be filename.php
    You need a server to launch php code
    You can use echo heredoc like here

    <body>
    
    <table class="altrowstable" id="alternatecolor">
    
    <?php
    if (!mysql_connect($db_host, $db_user, $db_pwd))
    {
    echo <<<_END
    <tr>
    <th>Failure</th><th>Player</th><th>Points</th><th>Played</th><th>Wins</th><th>Draws</th><th>Losses</th>
    </tr>
    _END
    }
    else
    {
    echo <<<_END
    <tr>
    <th>Success</th><th>Player</th><th>Points</th><th>Played</th><th>Wins</th><th>Draws</th><th>Losses</th>
    </tr>
    _END
    }
    ?>
    </table>
    </body>
    

    That seems to be working

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have thousands of HTML files to process using Groovy/Java and I need to
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.