kemper Posted April 10, 2008 Share Posted April 10, 2008 This may seem like an odd request, but I deal with some odd people that will believe 1:03 am is supposed to be 1:00 pm-ish. I need to avoid those issues, but the other website that I coordinate with utilized 1:03 am as a TBA time designation. I need to change my script to display "TBA" for that time designation. Assistance is greatly appreciated. <?php print "<table width='100%' class='tbl-border'>\n"; print "<tr> <th class='tbl2' colspan='6' align='left'> <font color='#ff0000'><b>Any games noted as POSTPONED have the league's permission for reschedule.</b> Coaches/managers should contact the opposing team manager and/or coach. With a coordinated effort, arrange for a suitable make-up date and time. Home Team coach/manager should contact their Club Field Scheduler to verify when fields are available.</font></th></tr><tr><th class='tbl2'>Status</th><th class='tbl2'>Date</th><th class='tbl2'>Time</th><th class='tbl2'>Home Team</th><th class='tbl2'>Visiting Team</th>"; if ($show_fields) print "<th class='tbl2'>Field</th>"; $queryscores = "SELECT sportsdb_wins.winid, sportsdb_wins.status, sportsdb_wins.windate, sportsdb_wins.wintime, sportsdb_wins.rf, sportsdb_wins.ra, sportsdb_wins.wincomments, sportsdb_wins.field, sportsdb_wins.field_no, sportsdb_teams2.teamname AS winningteam, sportsdb_teams.teamname AS losingteam FROM sportsdb_wins, sportsdb_teams AS sportsdb_teams2, sportsdb_teams, sportsdb_divs WHERE sportsdb_teams.teamdiv = sportsdb_divs.divid AND sportsdb_divs.conference = $confid AND sportsdb_teams2.teamid = sportsdb_wins.winner AND sportsdb_teams.teamid = sportsdb_wins.loser AND sportsdb_wins.winortie = 3"; // Sort by team if specified if (isset($_POST['teamtosort']) && $_POST['teamtosort'] != 'all') { $teamtosort = intval($_POST['teamtosort']); $queryscores .= " AND (sportsdb_wins.winner = $teamtosort OR sportsdb_wins.loser = $teamtosort)"; } $queryscores .= " ORDER BY windate ASC, wintime ASC"; $resultscores = mysql_query($queryscores); $numscores = mysql_numrows($resultscores); while ($scores = mysql_fetch_array($resultscores, MYSQL_ASSOC)) { $windateheader=$scores['windate']; $windateformatted=date("F d, Y",$windateheader); $wintime=$scores['wintime']; $hour=date('g',$wintime); $minute=date('i',$wintime); $ampm=date('a',$wintime); print "<tr><td class='tbl1'>{$scores['status']}</td><td class='tbl1'>$windateformatted</td><td class='tbl1'>" . $hour . ":" . $minute . $ampm . "</td><td class='tbl1'>{$scores['winningteam']}</td><td class='tbl1'>{$scores['losingteam']}</td>"; if ($show_fields) print "<td class='tbl1'>{$scores['field']} {$scores['field_no']}</td>"; } echo "</table>\n"; ?> The Time table field is setup as: `wintime` int(11) NOT NULL default '0', Link to comment https://forums.phpfreaks.com/topic/100417-solved-replace-103am-with-tba/ Share on other sites More sharing options...
marcus Posted April 10, 2008 Share Posted April 10, 2008 <?php $time = time(); $wintime = date("h:i", $time); if($wintime == '1:03'){ echo "TBA"; }else { echo $wintime; } ?> obvs. yours will be something different Link to comment https://forums.phpfreaks.com/topic/100417-solved-replace-103am-with-tba/#findComment-513533 Share on other sites More sharing options...
kemper Posted April 10, 2008 Author Share Posted April 10, 2008 I cannot seem to get it to work as I am declaring: $wintime=$scores['wintime']; $hour=date('g',$wintime); $minute=date('i',$wintime); $ampm=date('a',$wintime); and echoing > " . $hour . ":" . $minute . $ampm . " Link to comment https://forums.phpfreaks.com/topic/100417-solved-replace-103am-with-tba/#findComment-513541 Share on other sites More sharing options...
uniflare Posted April 10, 2008 Share Posted April 10, 2008 $windateheader=$scores['windate']; $windateformatted=date("F d, Y",$windateheader); $time = date('g:ia',$scores['wintime']); $time = ($time == "1:03am")? "TBA" : $time; print "<tr><td class='tbl1'>{$scores['status']}</td><td class='tbl1'>$windateformatted</td><td class='tbl1'>" . $time . "</td><td class='tbl1'>{$scores['winningteam']}</td><td class='tbl1'>{$scores['losingteam']}</td>"; hope this helps clear things up - also are you wanting to replace a time-range to be TBA or a specific time like above? Link to comment https://forums.phpfreaks.com/topic/100417-solved-replace-103am-with-tba/#findComment-513544 Share on other sites More sharing options...
kemper Posted April 10, 2008 Author Share Posted April 10, 2008 Thanks! That did the trick. I am unsure why the code was written that way for the time. It seems to tedious. TBA was what I wanted listed for 1:03am. Link to comment https://forums.phpfreaks.com/topic/100417-solved-replace-103am-with-tba/#findComment-513548 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.