Jump to content

[SOLVED] if time is 00:00:00 display???


kemper

Recommended Posts

In my schedules, I have table with field of:

`game_time` time NOT NULL default '00:00:00',

 

<?php

    // mySQL Table
$division_id = $_GET['division_id'];
$sql = "SELECT * FROM `f2007_scheduling` WHERE division_id='$division_id'";
$result = mysql_query($sql) or die(mysql_error());
$i = 0;

	// note change here
	$display_time = date("g:i a", strtotime($data['game_time'])); 


echo "</p>
<table width='100%' cellpadding='1' cellspacing='0' border='1' bordercolor='#3c64a0'>
<tr class='tbl-border'>
	<td><b><font size='1'>Status:</font></b></td>
	<td><b><font size='1'>Game ID:</font></b></td>
	<td><b><font size='1'>Date & Time:</font></b></td>
	<td><b><font size='1'>Teams:</font></b></td>
	<td><b><font size='1'>Field:</font></b></td>
</tr>\n";
    while ($row = mysql_fetch_array($result)) {
	echo "<tr>
	<td class='$tclass' valign='top'><font color='#ff0000' size='1'>".$row['status']."</font></td>
	<td class='$tclass' valign='top'><font size='1'>".$row['game_id']."</font></td>
	<td class='$tclass' valign='top'>
	<p style='margin-top: 0; margin-bottom: 0'><font size='1'>".$row['game_date']=date("l, F j",strtotime($row['game_date']))."</font></p>
	<p style='margin-top: 0; margin-bottom: 0'><font size='1'>at ".$row['game_time']=date("g:i a", strtotime($row['game_time']))."</font></p>
	</td>
	<td class='$tclass' valign='top'>
	<p style='margin-top: 0; margin-bottom: 0'><font size='1'>".$row['home_team']."  
	<font color='#FF0000'>(H)</font> vs.</font></p>
	<p style='margin-top: 0; margin-bottom: 0'><font size='1'>".$row['visit_team']." <font color='#FF0000'>(V)</font></font></p> 
	</td>
	<td class='$tclass' valign='top'><font size='1'>".$row['field']." ".$row['field_no']."</font></td>
</tr>\n";
}
echo "</table>\n";

  // mySQL ends
?>

I have some games that are blank due to field schedulers working on the specifics.

 

Instead of by time displaying as 12:00 am, I would like to insert TBA.  How do I do so?

Link to comment
Share on other sites

I have added it to my script, but is not displaying any differently.

 

<?php

    // mySQL Table
$division_id = $_GET['division_id'];
$sql = "SELECT * FROM `f2007_scheduling` WHERE division_id='$division_id'";
$result = mysql_query($sql) or die(mysql_error());
$i = 0;

$game_time = $row['game_time']

if ($game_time == '00:00:00')
{
echo "TBA" ;
}
else {
echo $game_time ;
}


	// note change here
	$display_time = date("g:i a", strtotime($data['game_time'])); 

echo "</p>

<table width='100%' cellpadding='1' cellspacing='0' border='1' bordercolor='#3c64a0'>
<tr class='tbl-border'>
	<td><b><font size='1'>Status:</font></b></td>
	<td><b><font size='1'>Game ID:</font></b></td>
	<td><b><font size='1'>Date & Time:</font></b></td>
	<td><b><font size='1'>Teams:</font></b></td>
	<td><b><font size='1'>Field:</font></b></td>
</tr>\n";
    while ($row = mysql_fetch_array($result)) {
	echo "<tr>
	<td class='$tclass' valign='top'><font color='#ff0000' size='1'>".$row['status']."</font></td>
	<td class='$tclass' valign='top'><font size='1'>".$row['game_id']."</font></td>
	<td class='$tclass' valign='top'>
	<p style='margin-top: 0; margin-bottom: 0'><font size='1'>".$row['game_date']=date("l, F j",strtotime($row['game_date']))."</font></p>
	<p style='margin-top: 0; margin-bottom: 0'><font size='1'>at ".$row['game_time']=date("g:i a", strtotime($row['game_time']))."</font></p>
	</td>
	<td class='$tclass' valign='top'>
	<p style='margin-top: 0; margin-bottom: 0'><font size='1'>".$row['home_team']."  
	<font color='#FF0000'>(H)</font> vs.</font></p>
	<p style='margin-top: 0; margin-bottom: 0'><font size='1'>".$row['visit_team']." <font color='#FF0000'>(V)</font></font></p> 
	</td>
	<td class='$tclass' valign='top'><font size='1'>".$row['field']." ".$row['field_no']."</font></td>
</tr>\n";
}
echo "</table>\n";

  // mySQL ends
?>

Link to comment
Share on other sites

12:00am is 00:00:00

 

so theirs no time set in the table

 

maybe

 

change

<?php
$game_time = $row['game_time']

if ($game_time == '00:00:00')
{
echo "TBA" ;
}
else {
echo $game_time ;
}

to

$game_time = $row['game_time'];
if(date("Ymd", $game_time) == 00000000)
{
$game_time = "TBA";
}

Link to comment
Share on other sites

The statement does not seem to do anything.

<?php
$game_time = $row['game_time']

if ($game_time == '00:00:00')
{
echo "TBA" ;
}
else {
echo $game_time ;
}

 

I changed

echo $game_time ;

to:

echo "OK" ;

 

Times display as they have. Times are displaying correctly as ".$row['game_time']=date("g:i a", strtotime($row['game_time']))."

 

Any other suggestions?

Link to comment
Share on other sites

<?php

    // mySQL Table
$division_id = $_GET['division_id'];
$game_time = $row['game_time'];
$sql = "SELECT * FROM `f2007_scheduling` WHERE division_id='$division_id'";
$result = mysql_query($sql) or die(mysql_error());
$i = 0;


if ($game_time == '00:00:00')
{
echo "TBA" ;
}
else {
echo $game_time ;
}


	// note change here
	$display_time = date("g:i a", strtotime($row['game_time'])); 

echo "</p>
<table width='100%' cellpadding='1' cellspacing='0' border='1' bordercolor='#3c64a0'>
<tr class='tbl-border'>
	<td><b><font size='1'>Status:</font></b></td>
	<td><b><font size='1'>Game ID:</font></b></td>
	<td><b><font size='1'>Date & Time:</font></b></td>
	<td><b><font size='1'>Teams:</font></b></td>
	<td><b><font size='1'>Field:</font></b></td>
</tr>\n";
    while ($row = mysql_fetch_array($result)) {
	echo "<tr>
	<td class='$tclass' valign='top'><font color='#ff0000' size='1'>".$row['status']."</font></td>
	<td class='$tclass' valign='top'><font size='1'>".$row['game_id']."</font></td>
	<td class='$tclass' valign='top'>
	<p style='margin-top: 0; margin-bottom: 0'><font size='1'>".$row['game_date']=date("l, F j",strtotime($row['game_date']))."</font></p>
	<p style='margin-top: 0; margin-bottom: 0'><font size='1'>at ".$row['game_time']=date("g:i a", strtotime($row['game_time']))."</font></p>
	</td>
	<td class='$tclass' valign='top'>
	<p style='margin-top: 0; margin-bottom: 0'><font size='1'>".$row['home_team']."  
	<font color='#FF0000'>(H)</font> vs.</font></p>
	<p style='margin-top: 0; margin-bottom: 0'><font size='1'>".$row['visit_team']." <font color='#FF0000'>(V)</font></font></p> 
	</td>
	<td class='$tclass' valign='top'><font size='1'>".$row['field']." ".$row['field_no']."</font></td>
</tr>\n";
}
echo "</table>\n";

  // mySQL ends

?>

 

00:00:00 time is still displaying as 12:00 am.  Any ideas where I am wrong here?

Link to comment
Share on other sites

i have a bad solution which i didn't want to say but if you need any solution..

 

<?php
$game_time = $row['game_time']
var_dump($game_time); //add this line
die;// add this line
if ($game_time == '00:00:00')
{
echo "TBA" ;
}
else {
echo $game_time ;
}

 

whats returned

Link to comment
Share on other sites

Could it be that the strtotime function interprets "TBA" as midnight? If, so then you would be overwriting TBA with midnight. Try this

 

<?php

$game_time = $row['game_time']

if ($game_time == '00:00:00')
{
  $display_time = "TBA" ;
}
else {
  $display_time = date("g:i a", strtotime($data['game_time'])); 
}


?>

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.