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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:28:59+00:00 2026-05-28T01:28:59+00:00

I have code that runs a query on the database and returns some data

  • 0

I have code that runs a query on the database and returns some data and displays it.
All very simple. I’ve tested the query and it work’s perfectly.

So somewhere between the query being executed and me displaying the data, it’s not working.

$q = "SELECT u.username, r.position, r.score, r.winner, t.team FROM ".TBL_FOOT_TOUR_ROUNDS." r
                      LEFT JOIN ".TBL_USERS." u ON u.id = r.winner
                      LEFT JOIN ".TBL_FOOT_TOUR_PLAYERS." pl ON pl.userid = r.winner
                      LEFT JOIN ".TBL_FOOT_TEAMS." t ON t.id = pl.team
                      WHERE r.tourid = '$tour_id' && r.round = '$i' ORDER BY r.position";
                $result = $database->query($q);
                ?>
                <div class="vertical-holder">
                    <div class="vertical-header"><p><?php echo $roundName[$i]; ?></p></div>
                    <?php
                    while($row=mysql_fetch_assoc($result)){
                        extract($row);
                        if($k&1){
                            ?>
                            <div class="horizontal-holder<?php echo $j; ?>">
                                <div class="white-holder">
                                    <div class="player-holder">
                                        <?php
                                        if($winner == 0){
                                            echo "<p>TBC</p>";
                                        }
                                        else{
                                            echo "<p><a href='/profile.php?id=$winner'>$username</a><br />$team</p>";
                                        }
                                        ?>
                                    </div>
                                    <div class="score-holder">
                                        <?php 
                                        if($score == NULL){
                                            echo "<p>-</p>";
                                        }
                                        else{
                                            echo "<p>$score</p>";
                                        }
                                        ?>
                                    </div>
                                </div>
                            <?php
                        }

That’s the snippet of code that’s (what I believe to be) relevant.

The score is showing as ‘-‘ all the time even when a score is present.

The rest of the returned data shows no problem.

Can anyone see why the score variable isn’t showing?

Thanks

  • 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-28T01:28:59+00:00Added an answer on May 28, 2026 at 1:28 am
    <?php 
        if($score == NULL){
            echo "<p>-</p>";
        } else {
            echo "<p>$score</p>";
        }
    ?>
    

    you got it wrong. if the value in the database is null, $score will not be null, it will be the string “null”. so try

    <?php 
        if(strtoupper($score) === "NULL"){
            echo "<p>-</p>";
        } else {
            echo "<p>$score</p>";
        }
    ?>
    

    🙂

    alternatively you can create some utility function that changes a variable:

    function nullify(&$data) {
        if(strtoupper($data) === "NULL") {
            $data = NULL;
        }
    }
    

    and then call it like this:

    nullify($score);
    

    if $score should be set to null, it will be null after the call. then you can keep your logic the way it is ^^

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

Sidebar

Related Questions

below i have a code that runs in most of my simple programs ..
I have a simple jQuery code that runs on a web page that has
I have the following SQL code that runs against a Change Request database. Each
I have some code that compiles and runs on MSVC++ but will not compile
I have to call some code in a SharePoint site that runs under the
I have a PHP script that runs database queries. Now, if a query fails,
I have a dynamic query that returns around 590,000 records. It runs successfully the
I have code that looks like: //System.Data.IDataRecord dr try { Consolidated = Utility.NullConvert.ToBool(dr[Constants.Data.Columns.cConsolidated], false);
I have a very simple ASP.Net page that acts as a front end for
I have a morning process that runs in an old MS Access database. One

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.