Jump to content

[SOLVED] Time Formatting


kemper

Recommended Posts

<?php
require_once "maincore.php";
require_once "subheader.php";
require_once "side_left.php";
include LOCALE.LOCALESET."sched.php";

//if (!checkrights("FR")) fallback("../index.php");

//int mktime ( [int $hour [, int $minute [, int $second [, int $month [, int $day [, int $year [, int $is_dst]]]]]]] )
$time = split(":", $data['time']);
$new_time = mktime($time[0], $time[1], $time[2], 1, 1, 1999);

if (isset($_POST['edit_sched'])) {
$time = stripinput($_POST['time']);
$home_field = stripinput($_POST['home_field']);
$field_no = stripinput($_POST['field_no']);
$result = dbquery("UPDATE f2007_scheduling SET sched_user='".$userdata['user_id']."', time='$time', home_field='$home_field', field_no='$field_no' WHERE id='$id' ");
//$result = dbquery("UPDATE ".$db_prefix."faq_cats SET faq_cat_name='$faq_cat_name' WHERE faq_cat_id='$faq_cat_id'");
}
if ($step == "edit"){
//$data = dbarray(dbquery(
//		"SELECT ter.*, user_id,user_name FROM f2007_scheduling ter
//		LEFT JOIN ".$db_prefix."users tusr ON ter.sched_user=tusr.user_id
//		WHERE id='$id'"
//	));
$data = dbarray(dbquery("SELECT * FROM f2007_scheduling WHERE id='$id'"));

opentable ("Fall Schedules");
print ("$data['time']\n");
closetable ();
}

opentable ($locale['sched001']);
$sql = dbquery(
"SELECT ter.*, user_id,user_name FROM f2007_scheduling ter
LEFT JOIN ".$db_prefix."users tusr ON ter.sched_user=tusr.user_id
ORDER BY date ASC"
);
if (dbrows($sql)) {
$i = 0;
echo "<table width='100%' cellpadding='0' cellspacing='1' class='tbl-border'>
<tr>
<td class='tbl2' width='55%'><b>Schedules <font size='1'>(Date - Age Division - Home vs. Visitors)</font></b>:</td>
<td align='center' width='15%' class='tbl2'><b>Time/Notes</b>:</td>
<td align='center' width='15%' class='tbl2'><b>Field</b>:</td>
<td align='center' width='15%' class='tbl2'><b>Options:</b></td>
</tr>\n";
while ($data = dbarray($sql)) {
	$i % 2 == 0 ? $tclass="tbl1" : $tclass="tbl2";
	echo "<tr>
<td class='$tclass' width='55%'><font size='1'><font color='#0000FF'>".$data['date']." - </font>".$data['age']." ".$data['division']." - ".$data['home_team']." 
vs. ".$data['visiting_team']."</font></font></td>
<td align='center' class='$tclass' width='15%'><font size='1'>
<span style='background-color: #FFFF00'>".$data['notes']."</span></font></td>
<td align='center' class='$tclass' width='15%'><font size='1'>".$data['home_field']." ".$data['field_no']."</font></td>
<td align='center' class='$tclass' width='15%'><a href='".FUSION_SELF."?step=edit&id=".$data['id']."'>".$locale['sched002']."</a></td>
</tr>\n";
}
echo "</table>\n";
} else {
echo "<center><br>\n".$locale['sched141']."<br><br>\n</center>\n";
}
closetable();

echo "</td>\n";
require_once BASEDIR."footer.php";
?>

 

^ Is with print ("$data['time']

 

My original code is:

<?php
require_once "maincore.php";
require_once "subheader.php";
require_once "side_left.php";
include LOCALE.LOCALESET."sched.php";

//if (!checkrights("FR")) fallback("../index.php");

//int mktime ( [int $hour [, int $minute [, int $second [, int $month [, int $day [, int $year [, int $is_dst]]]]]]] )
$time = split(":", $data['time']);
$new_time = mktime($time[0], $time[1], $time[2], 1, 1, 1999);

if (isset($_POST['edit_sched'])) {
$time = stripinput($_POST['time']);
$home_field = stripinput($_POST['home_field']);
$field_no = stripinput($_POST['field_no']);
$result = dbquery("UPDATE f2007_scheduling SET sched_user='".$userdata['user_id']."', time='$time', home_field='$home_field', field_no='$field_no' WHERE id='$id' ");
//$result = dbquery("UPDATE ".$db_prefix."faq_cats SET faq_cat_name='$faq_cat_name' WHERE faq_cat_id='$faq_cat_id'");
}
if ($step == "edit"){
//$data = dbarray(dbquery(
//		"SELECT ter.*, user_id,user_name FROM f2007_scheduling ter
//		LEFT JOIN ".$db_prefix."users tusr ON ter.sched_user=tusr.user_id
//		WHERE id='$id'"
//	));
$data = dbarray(dbquery("SELECT * FROM f2007_scheduling WHERE id='$id'"));

opentable ($locale['sched001']);
echo "<form name='reportform' method='post' action='".FUSION_SELF."?id=$id'>
".$locale['sched120']."
<table align='center' cellspacing='5' cellpadding='5' class='tbl' width='375'>
<tr>
<td width='124' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'><b>Age:</b></td>
<td width='216' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'>".$data['age']."</td>
</tr>
<tr>
<td valign='top' width='124'>
<p style='margin-top: 0; margin-bottom: 0'><b>Division:</b></td>
<td valign='top' width='216'>
<p style='margin-top: 0; margin-bottom: 0'>".$data['division']."</p>
</td>
</tr>
<tr>
<td width='124' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'><b>Game ID:</b></td>
<td width='216' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'>".$data['id']."</td>
</tr>
<tr>
<td width='124' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'><b>Date:</b></td>
<td width=216' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'>".$data['date']=date("D, F j, Y",strtotime($date['date']))."</td>
</tr>
<tr>
<td width='124' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'><b>Time/Notes:</b></td>
<td width='216' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'>
<span style='background-color: #FFFF00'>".$data['notes']."</span></td>
</tr>
<tr>
<td valign='top' width='124'>
<p style='margin-top: 0; margin-bottom: 0'><b>Time</b></td>
<td valign='top' width='216'>
<p style='margin-top: 0; margin-bottom: 0'>".date("h:i a", $new_time)."</td>
</tr>
<tr>
<td width='124' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'><b>Match-up:</b></td>
<td width='216' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'>".$data['home_team']."</p>
<p style='margin-top: 0; margin-bottom: 0'><font color='#0000FF'>vs.</font> ".$data['visiting_team']."</td>
</tr>
<tr>
<td width='124' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'><b>Field:</b></td>
<td width='216' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'><input type='text' name='home_field' value='".$data['home_field']."' class='textbox' style='width:150px;'></td>
</tr>
<tr>
<td width='124' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'><b>Field # or Name:</b></td>
<td width='216' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'><input type='text' name='field_no' value='".$data['field_no']."' class='textbox' style='width:100px;'></td>
</tr>
<tr>
<td align='center' colspan='2'>
<input type='submit' name='edit_sched' value='".$locale['sched135']."' class='button'></td>
</tr>
</table>
</form>\n";
closetable ();
}

opentable ($locale['sched001']);
$sql = dbquery(
"SELECT ter.*, user_id,user_name FROM f2007_scheduling ter
LEFT JOIN ".$db_prefix."users tusr ON ter.sched_user=tusr.user_id
ORDER BY date ASC"
);
if (dbrows($sql)) {
$i = 0;
echo "<table width='100%' cellpadding='0' cellspacing='1' class='tbl-border'>
<tr>
<td class='tbl2' width='55%'><b>Schedules <font size='1'>(Date - Age Division - Home vs. Visitors)</font></b>:</td>
<td align='center' width='15%' class='tbl2'><b>Time/Notes</b>:</td>
<td align='center' width='15%' class='tbl2'><b>Field</b>:</td>
<td align='center' width='15%' class='tbl2'><b>Options:</b></td>
</tr>\n";
while ($data = dbarray($sql)) {
	$i % 2 == 0 ? $tclass="tbl1" : $tclass="tbl2";
	echo "<tr>
<td class='$tclass' width='55%'><font size='1'><font color='#0000FF'>".$data['date']." - </font>".$data['age']." ".$data['division']." - ".$data['home_team']." 
vs. ".$data['visiting_team']."</font></font></td>
<td align='center' class='$tclass' width='15%'><font size='1'>
<span style='background-color: #FFFF00'>".$data['notes']."</span></font></td>
<td align='center' class='$tclass' width='15%'><font size='1'>".$data['home_field']." ".$data['field_no']."</font></td>
<td align='center' class='$tclass' width='15%'><a href='".FUSION_SELF."?step=edit&id=".$data['id']."'>".$locale['sched002']."</a></td>
</tr>\n";
}
echo "</table>\n";
} else {
echo "<center><br>\n".$locale['sched141']."<br><br>\n</center>\n";
}
closetable();

echo "</td>\n";
require_once BASEDIR."footer.php";
?>

Link to comment
Share on other sites

<?php
header("Content-type:text/xml");
$not_completed = "tesT";
echo '<?xml version="1.0" encoding="utf-8"?>
<graph>
<general_settings bg_color="FFFFFF" />
<header text="Jobs for Expansion Installation - Integration" font="Verdana" color="000000" size="18" />
<subheader text="" font="Verdana" color="000000" size="15" />
<legend font="Verdana" font_color="000000" font_size="11" bgcolor="FFFFFF" alternate_bg_color="FFF9E1" border_color="BFBFBF" />
<legend_popup font="Verdana" bgcolor="FFFFE3" font_size="10" />
<pie_chart radius="100" height="35" angle_slope="45" alpha_sides="60" alpha_lines="20" />
	<data name="Completed" value="' . $not_completed . '" color="FF0000" />
	<data name="Not Completed" value="'.$completed.'" color="333333" />
</graph>';
?>

<?php
require_once "maincore.php";
require_once "subheader.php";
require_once "side_left.php";
include LOCALE.LOCALESET."sched.php";

//if (!checkrights("FR")) fallback("../index.php");

//int mktime ( [int $hour [, int $minute [, int $second [, int $month [, int $day [, int $year [, int $is_dst]]]]]]] )
$time = split(":", $data['time']);
$new_time = mktime($time[0], $time[1], $time[2], 1, 1, 1999);

if (isset($_POST['edit_sched'])) {
$time = stripinput($_POST['time']);
$home_field = stripinput($_POST['home_field']);
$field_no = stripinput($_POST['field_no']);
$result = dbquery("UPDATE f2007_scheduling SET sched_user='".$userdata['user_id']."', time='$time', home_field='$home_field', field_no='$field_no' WHERE id='$id' ");
//$result = dbquery("UPDATE ".$db_prefix."faq_cats SET faq_cat_name='$faq_cat_name' WHERE faq_cat_id='$faq_cat_id'");
}
if ($step == "edit"){
//$data = dbarray(dbquery(
//		"SELECT ter.*, user_id,user_name FROM f2007_scheduling ter
//		LEFT JOIN ".$db_prefix."users tusr ON ter.sched_user=tusr.user_id
//		WHERE id='$id'"
//	));
$data = dbarray(dbquery("SELECT * FROM f2007_scheduling WHERE id='$id'"));
	$time = split(":", $time);
	$new_time = mktime($time[0], $time[1], $time[2], 1, 1, 1999);

opentable ($locale['sched001']);
echo "<form name='reportform' method='post' action='".FUSION_SELF."?id=$id'>
".$locale['sched120']."
<table align='center' cellspacing='5' cellpadding='5' class='tbl' width='375'>
<tr>
<td width='124' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'><b>Age:</b></td>
<td width='216' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'>".$data['age']."</td>
</tr>
<tr>
<td valign='top' width='124'>
<p style='margin-top: 0; margin-bottom: 0'><b>Division:</b></td>
<td valign='top' width='216'>
<p style='margin-top: 0; margin-bottom: 0'>".$data['division']."</p>
</td>
</tr>
<tr>
<td width='124' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'><b>Game ID:</b></td>
<td width='216' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'>".$data['id']."</td>
</tr>
<tr>
<td width='124' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'><b>Date:</b></td>
<td width=216' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'>".$data['date']=date("D, F j, Y",strtotime($date['date']))."</td>
</tr>
<tr>
<td width='124' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'><b>Time/Notes:</b></td>
<td width='216' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'>
<span style='background-color: #FFFF00'>".$data['notes']."</span></td>
</tr>
<tr>
<td valign='top' width='124'>
<p style='margin-top: 0; margin-bottom: 0'><b>Time</b></td>
<td valign='top' width='216'>
<p style='margin-top: 0; margin-bottom: 0'>".date("h:i a", $new_time)."</td>
</tr>
<tr>
<td width='124' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'><b>Match-up:</b></td>
<td width='216' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'>".$data['home_team']."</p>
<p style='margin-top: 0; margin-bottom: 0'><font color='#0000FF'>vs.</font> ".$data['visiting_team']."</td>
</tr>
<tr>
<td width='124' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'><b>Field:</b></td>
<td width='216' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'><input type='text' name='home_field' value='".$data['home_field']."' class='textbox' style='width:150px;'></td>
</tr>
<tr>
<td width='124' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'><b>Field # or Name:</b></td>
<td width='216' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'><input type='text' name='field_no' value='".$data['field_no']."' class='textbox' style='width:100px;'></td>
</tr>
<tr>
<td align='center' colspan='2'>
<input type='submit' name='edit_sched' value='".$locale['sched135']."' class='button'></td>
</tr>
</table>
</form>\n";
closetable ();
}

opentable ($locale['sched001']);
$sql = dbquery(
"SELECT ter.*, user_id,user_name FROM f2007_scheduling ter
LEFT JOIN ".$db_prefix."users tusr ON ter.sched_user=tusr.user_id
ORDER BY date ASC"
);
if (dbrows($sql)) {
$i = 0;
echo "<table width='100%' cellpadding='0' cellspacing='1' class='tbl-border'>
<tr>
<td class='tbl2' width='55%'><b>Schedules <font size='1'>(Date - Age Division - Home vs. Visitors)</font></b>:</td>
<td align='center' width='15%' class='tbl2'><b>Time/Notes</b>:</td>
<td align='center' width='15%' class='tbl2'><b>Field</b>:</td>
<td align='center' width='15%' class='tbl2'><b>Options:</b></td>
</tr>\n";
while ($data = dbarray($sql)) {
	$i % 2 == 0 ? $tclass="tbl1" : $tclass="tbl2";

	echo "<tr>
<td class='$tclass' width='55%'><font size='1'><font color='#0000FF'>".$data['date']." - </font>".$data['age']." ".$data['division']." - ".$data['home_team']." 
vs. ".$data['visiting_team']."</font></font></td>
<td align='center' class='$tclass' width='15%'><font size='1'>
<span style='background-color: #FFFF00'>".$data['notes']."</span></font></td>
<td align='center' class='$tclass' width='15%'><font size='1'>".$data['home_field']." ".$data['field_no']."</font></td>
<td align='center' class='$tclass' width='15%'><a href='".FUSION_SELF."?step=edit&id=".$data['id']."'>".$locale['sched002']."</a></td>
</tr>\n";
}
echo "</table>\n";
} else {
echo "<center><br>\n".$locale['sched141']."<br><br>\n</center>\n";
}
closetable();

echo "</td>\n";
require_once BASEDIR."footer.php";
?>

 

 

Should work.

Link to comment
Share on other sites

Thats what gives me 12:00 am.

 

if it matters, my table is set up as:

CREATE TABLE `f2007_scheduling` (
 `club_id` smallint(3) NOT NULL default '0',
 `status` text NOT NULL,
 `age` text NOT NULL,
 `division` text NOT NULL,
 `id` text NOT NULL,
 `date` date NOT NULL default '0000-00-00',
 `notes` text NOT NULL,
 `time` time NOT NULL default '00:00:00',
 `home` text NOT NULL,
 `h_score` text NOT NULL,
 `home_team` text NOT NULL,
 `hteam_no` text NOT NULL,
 `home_field` text NOT NULL,
 `field_no` text NOT NULL,
 `visitors` text NOT NULL,
 `v_score` text NOT NULL,
 `visiting_team` text NOT NULL,
 `vteam_no` text NOT NULL,
 `visitor_field` text NOT NULL,
 `sched_user` smallint(5) unsigned NOT NULL default '0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

-- 
-- Dumping data for table `f2007_scheduling`
-- 

INSERT INTO `f2007_scheduling` VALUES (1, 'ok', 'U-7', 'Red', '02455646', '2007-10-05', 'before Noon', '12:00:00', '1', '', 'Team 1', '20456', 'Field C', '', '2', '', 'Team 3', '123465', 'Field B', 1);
INSERT INTO `f2007_scheduling` VALUES (2, 'ok', 'U-14', 'Blue', '789643', '2007-09-06', '', '00:00:00', '5', '', 'Team 5', '7452', 'Field P', '8', '3', '', 'Team 7', '8964', 'Field F', 1);

Link to comment
Share on other sites

OK,  Now I tried this:

$time = "20:18:05"; // make this your pull from the database.

 

$display_time = date("h:i A", strtotime($time));

 

will display as

 

08:18 PM

 

Snowdog

 

The good news is...  I did not get 12:00 am.  Both test records that I created in my table display as 5:59 PM.  Where is this time coming from?

 

Any suggestions?

Link to comment
Share on other sites

Well for starters the data in your database, is 12:00 am and 12:00 pm... Let's do this to do a test k?

 

<?php
mysql_connect("localhost", "yourusername", "yourpassword");
mysql_select_db("yourdbname");

// insert a statment for 1:05 PM for testing.
mysql_query("INSERT INTO `f2007_scheduling` VALUES (2, 'ok', 'U-14', 'Blue', '789643', '2007-09-06', '', '13:05:00', '5', '', 'Team 5', '7452', 'Field P', '8', '3', '', 'Team 7', '8964', 'Field F', 1);");

$result = mysql_query("select time from f2007_scheduling");

while ($row = mysql_fetch_assoc($result)) {
        echo "Time of " . $row['time'] . " is converted to " . date("h:i A", strtotime($row['time']));
}
?>

 

See if that works, if it does the issue is arising in how you are assigning the time variable in your script as it is incorrect.

 

 

EDIT: If that does work, try running this re-vamped version of your code and see what happens:

 

<?php
require_once "maincore.php";
require_once "subheader.php";
require_once "side_left.php";
include LOCALE.LOCALESET."sched.php";

//if (!checkrights("FR")) fallback("../index.php");

if (isset($_POST['edit_sched'])) {
$time = stripinput($_POST['time']);
$home_field = stripinput($_POST['home_field']);
$field_no = stripinput($_POST['field_no']);
$result = dbquery("UPDATE f2007_scheduling SET sched_user='".$userdata['user_id']."', time='$time', home_field='$home_field', field_no='$field_no' WHERE id='$id' ");
//$result = dbquery("UPDATE ".$db_prefix."faq_cats SET faq_cat_name='$faq_cat_name' WHERE faq_cat_id='$faq_cat_id'");
}
if ($step == "edit"){
//$data = dbarray(dbquery(
//		"SELECT ter.*, user_id,user_name FROM f2007_scheduling ter
//		LEFT JOIN ".$db_prefix."users tusr ON ter.sched_user=tusr.user_id
//		WHERE id='$id'"
//	));
$data = dbarray(dbquery("SELECT * FROM f2007_scheduling WHERE id='$id'"));

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

opentable ($locale['sched001']);
echo "<form name='reportform' method='post' action='".FUSION_SELF."?id=$id'>
".$locale['sched120']."
<table align='center' cellspacing='5' cellpadding='5' class='tbl' width='375'>
<tr>
<td width='124' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'><b>Age:</b></td>
<td width='216' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'>".$data['age']."</td>
</tr>
<tr>
<td valign='top' width='124'>
<p style='margin-top: 0; margin-bottom: 0'><b>Division:</b></td>
<td valign='top' width='216'>
<p style='margin-top: 0; margin-bottom: 0'>".$data['division']."</p>
</td>
</tr>
<tr>
<td width='124' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'><b>Game ID:</b></td>
<td width='216' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'>".$data['id']."</td>
</tr>
<tr>
<td width='124' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'><b>Date:</b></td>
<td width=216' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'>".$data['date']=date("D, F j, Y",strtotime($data['date']))."</td>
</tr>
<tr>
<td width='124' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'><b>Time/Notes:</b></td>
<td width='216' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'>
<span style='background-color: #FFFF00'>".$data['notes']."</span></td>
</tr>
<tr>
<td valign='top' width='124'>
<p style='margin-top: 0; margin-bottom: 0'><b>Time</b></td>
<td valign='top' width='216'>
<p style='margin-top: 0; margin-bottom: 0'>".$display_time."</td>
</tr>
<tr>
<td width='124' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'><b>Match-up:</b></td>
<td width='216' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'>".$data['home_team']."</p>
<p style='margin-top: 0; margin-bottom: 0'><font color='#0000FF'>vs.</font> ".$data['visiting_team']."</td>
</tr>
<tr>
<td width='124' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'><b>Field:</b></td>
<td width='216' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'><input type='text' name='home_field' value='".$data['home_field']."' class='textbox' style='width:150px;'></td>
</tr>
<tr>
<td width='124' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'><b>Field # or Name:</b></td>
<td width='216' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'><input type='text' name='field_no' value='".$data['field_no']."' class='textbox' style='width:100px;'></td>
</tr>
<tr>
<td align='center' colspan='2'>
<input type='submit' name='edit_sched' value='".$locale['sched135']."' class='button'></td>
</tr>
</table>
</form>\n";
closetable ();
}

opentable ($locale['sched001']);
$sql = dbquery(
"SELECT ter.*, user_id,user_name FROM f2007_scheduling ter
LEFT JOIN ".$db_prefix."users tusr ON ter.sched_user=tusr.user_id
ORDER BY date ASC"
);
if (dbrows($sql)) {
$i = 0;
echo "<table width='100%' cellpadding='0' cellspacing='1' class='tbl-border'>
<tr>
<td class='tbl2' width='55%'><b>Schedules <font size='1'>(Date - Age Division - Home vs. Visitors)</font></b>:</td>
<td align='center' width='15%' class='tbl2'><b>Time/Notes</b>:</td>
<td align='center' width='15%' class='tbl2'><b>Field</b>:</td>
<td align='center' width='15%' class='tbl2'><b>Options:</b></td>
</tr>\n";
while ($data = dbarray($sql)) {
	$i % 2 == 0 ? $tclass="tbl1" : $tclass="tbl2";

	echo "<tr>
<td class='$tclass' width='55%'><font size='1'><font color='#0000FF'>".$data['date']." - </font>".$data['age']." ".$data['division']." - ".$data['home_team']." 
vs. ".$data['visiting_team']."</font></font></td>
<td align='center' class='$tclass' width='15%'><font size='1'>
<span style='background-color: #FFFF00'>".$data['notes']."</span></font></td>
<td align='center' class='$tclass' width='15%'><font size='1'>".$data['home_field']." ".$data['field_no']."</font></td>
<td align='center' class='$tclass' width='15%'><a href='".FUSION_SELF."?step=edit&id=".$data['id']."'>".$locale['sched002']."</a></td>
</tr>\n";
}
echo "</table>\n";
} else {
echo "<center><br>\n".$locale['sched141']."<br><br>\n</center>\n";
}
closetable();

echo "</td>\n";
require_once BASEDIR."footer.php";
?>

Link to comment
Share on other sites

<?php
require_once "maincore.php";
require_once "subheader.php";
require_once "side_left.php";
include LOCALE.LOCALESET."sched.php";

//if (!checkrights("FR")) fallback("../index.php");

if (isset($_POST['edit_sched'])) {
$time = stripinput($_POST['time']);
$home_field = stripinput($_POST['home_field']);
$field_no = stripinput($_POST['field_no']);
$result = dbquery("UPDATE f2007_scheduling SET sched_user='".$userdata['user_id']."', time='$time', home_field='$home_field', field_no='$field_no' WHERE id='$id' ");
//$result = dbquery("UPDATE ".$db_prefix."faq_cats SET faq_cat_name='$faq_cat_name' WHERE faq_cat_id='$faq_cat_id'");
}
if ($step == "edit"){
//$data = dbarray(dbquery(
//		"SELECT ter.*, user_id,user_name FROM f2007_scheduling ter
//		LEFT JOIN ".$db_prefix."users tusr ON ter.sched_user=tusr.user_id
//		WHERE id='$id'"
//	));
$data = dbarray(dbquery("SELECT * FROM f2007_scheduling WHERE id='$id'"));

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

opentable ($locale['sched001']);
echo "<form name='reportform' method='post' action='".FUSION_SELF."?id=$id'>
".$locale['sched120']."
<table align='center' cellspacing='5' cellpadding='5' class='tbl' width='375'>
<tr>
<td width='124' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'><b>Age:</b></td>
<td width='216' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'>".$data['age']."</td>
</tr>
<tr>
<td valign='top' width='124'>
<p style='margin-top: 0; margin-bottom: 0'><b>Division:</b></td>
<td valign='top' width='216'>
<p style='margin-top: 0; margin-bottom: 0'>".$data['division']."</p>
</td>
</tr>
<tr>
<td width='124' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'><b>Game ID:</b></td>
<td width='216' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'>".$data['id']."</td>
</tr>
<tr>
<td width='124' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'><b>Date:</b></td>
<td width=216' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'>".$data['date']=date("D, F j, Y",strtotime($data['date']))."</td>
</tr>
<tr>
<td width='124' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'><b>Time/Notes:</b></td>
<td width='216' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'>
<span style='background-color: #FFFF00'>".$data['notes']."</span></td>
</tr>
<tr>
<td valign='top' width='124'>
<p style='margin-top: 0; margin-bottom: 0'><b>Time</b></td>
<td valign='top' width='216'>
<p style='margin-top: 0; margin-bottom: 0'>".$display_time."</td>
</tr>
<tr>
<td width='124' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'><b>Match-up:</b></td>
<td width='216' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'>".$data['home_team']."</p>
<p style='margin-top: 0; margin-bottom: 0'><font color='#0000FF'>vs.</font> ".$data['visiting_team']."</td>
</tr>
<tr>
<td width='124' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'><b>Field:</b></td>
<td width='216' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'><input type='text' name='home_field' value='".$data['home_field']."' class='textbox' style='width:150px;'></td>
</tr>
<tr>
<td width='124' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'><b>Field # or Name:</b></td>
<td width='216' valign='top'>
<p style='margin-top: 0; margin-bottom: 0'><input type='text' name='field_no' value='".$data['field_no']."' class='textbox' style='width:100px;'></td>
</tr>
<tr>
<td align='center' colspan='2'>
<input type='submit' name='edit_sched' value='".$locale['sched135']."' class='button'></td>
</tr>
</table>
</form>\n";
closetable ();
}

opentable ($locale['sched001']);
$sql = dbquery(
"SELECT ter.*, user_id,user_name FROM f2007_scheduling ter
LEFT JOIN ".$db_prefix."users tusr ON ter.sched_user=tusr.user_id
ORDER BY date ASC"
);
if (dbrows($sql)) {
$i = 0;
echo "<table width='100%' cellpadding='0' cellspacing='1' class='tbl-border'>
<tr>
<td class='tbl2' width='55%'><b>Schedules <font size='1'>(Date - Age Division - Home vs. Visitors)</font></b>:</td>
<td align='center' width='15%' class='tbl2'><b>Time/Notes</b>:</td>
<td align='center' width='15%' class='tbl2'><b>Field</b>:</td>
<td align='center' width='15%' class='tbl2'><b>Options:</b></td>
</tr>\n";
while ($data = dbarray($sql)) {
	$i % 2 == 0 ? $tclass="tbl1" : $tclass="tbl2";

	echo "<tr>
<td class='$tclass' width='55%'><font size='1'><font color='#0000FF'>".$data['date']." - </font>".$data['age']." ".$data['division']." - ".$data['home_team']." 
vs. ".$data['visiting_team']."</font></font></td>
<td align='center' class='$tclass' width='15%'><font size='1'>
<span style='background-color: #FFFF00'>".$data['notes']."</span></font></td>
<td align='center' class='$tclass' width='15%'><font size='1'>".$data['home_field']." ".$data['field_no']."</font></td>
<td align='center' class='$tclass' width='15%'><a href='".FUSION_SELF."?step=edit&id=".$data['id']."'>".$locale['sched002']."</a></td>
</tr>\n";
}
echo "</table>\n";
} else {
echo "<center><br>\n".$locale['sched141']."<br><br>\n</center>\n";
}
closetable();

echo "</td>\n";
require_once BASEDIR."footer.php";
?>

 

Well it seems as though the function works, try replacing the old code with this one and run it.

Link to comment
Share on other sites

Seems wierd... the 08:30:00 displays 8:30 AM and 16:00:00 displays as 4:00 PM. Now, the new record that you had me insert also reads as 4:00 PM, yet database has it as 01:05:00. How? Why?

 

Progress is being made, I do appreciate it.

Link to comment
Share on other sites

Dammit!  I am an idiot for not reading the new record.  It seems to be working correctly.  The new record has the same id as one of my original records.  It all good.  Thanks!

 

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.