Jump to content

Changing the output in a while loop


mdmartiny

Recommended Posts

I am trying to write some code for my website. I pull information out of a database using a while loop. What am I trying to figure out is how to change some of the information. Some of the information used by the database is not there. It is not there cause I lost it and don't know what to put in place.

 

The missing information is a Date Field. In the database if the field is blank it displays 0000-00-00. On the page it displays 01-01-1970. What I want to do is when the date is 01-01-1970 it actually shows N/A.

 

How would I go about doing this?

 

This is the code that I am using to draw the information from the database.

if ($year == 'other') {
        $sqlC = "SELECT * FROM `ttmautos` WHERE YEAR(date_return) < 2008 ORDER BY `date_return` DESC";
        $resultC = mysql_query($sqlC) or die(mysql_error());
        if (mysql_num_rows($resultC) == 0) {
            echo "There currently are no signatures in the database from $year";
        } else {
            $autographs = "<table id='ttm'>\n";
        $autographs .= "<tr class='first'><th>Player</th><th>Date Sent</th><th>Date Returned</th><th>Item Signed</th><th>Project</th></tr>\n";
        $autographs .= "<tr><td id=\"blank\"></td><td id=\"blank\"></td><td id=\"blank\"></td><td id=\"blank\"></td><td id=\"blank\"></td></tr>\n";
        while ($row = mysql_fetch_assoc($resultC)) {
		$category = $row['category'];
            $fname = $row['f_name'];
            $lname = $row['l_name'];
            $dsent = date('m-d-Y', strtotime($row['date_sent']));
            $dreturn = date('m-d-Y', strtotime($row['date_return']));
            $ireturn = $row['item_return'];
            $project = $row['project'];
            $autographs .= "<tr><td class=\"auto_cell\">$fname $lname</td>";
            $autographs .= "<td class=\"auto_cell\">$dsent</td>";
            $autographs .= "<td class=\"auto_cell\">$dreturn</td>";
            $autographs .= "<td class=\"auto_cell\"><a href=\"signatures.php?c=$category&l=$lname&f=$fname\">$ireturn</a></td>";
            $autographs .= "<td class=\"auto_cell\"><a href='projects/$project.php'>$project</a></td></tr>\n";
            }
            $autographs .= "</table>";
            echo "$autographs";
        }
    }
}

 

I hope that I have given enough information to help me out with this issue.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.