Forum Moderators: coopster
TEXT[ (M) ]
A TEXT column with a maximum length of 65,535 (216 – 1) characters.
a bit large really but I guess varchar is the same after 5.0.3
what size are they? do you know?
I am just trying to see if it is even worth changing. Removing the three date fileds and making it one single one would make things much easier and store a timestamp in the db, not a mysql timestamp column.
this would cause a few things to be changed, actually a fair number but would be a much better way to go.
One option to sort on a numeric month is to create a table with two columns:
create table MonthLink (
MonthName char(15) not null primary key,
MonthNo int unsigned not null
);
Populate this table with all month pairs:
('January', 1), ('February', 2), ... and so on.
If not all your months are in this standard format (eg. some may be all lowercase?), run a separate query first to identify all the distinct month values:
select distinct TSpickMonth from TripLog;
Then insert ('Jan.', 1), ('january', 1), etc. as required.
Having done that, you can rerun the original query:
select TripLog.* from TripLog,MonthLink
where TSpickMonth = MonthName
order by SpickYear, MonthNo, SpickDay;
Be careful that you've added all distinct values of TSpickMonth to MonthLink, or the join will not include all records from the primary file.
That's one option, assuming your month field is character.
[edited by: directrix at 9:04 pm (utc) on Nov. 8, 2005]
you would store a string of numbers for each date
you could create these using the mktime function we used before. You would then be able to skip a step when you get them from the database since you are using mktime to convert the dates for output to the browser. That step would no longer be required.
selection and sorting based on those dates would also be much easier ;)
This can give you a start [webmasterworld.com...] (attention on msg #4)
If you do it, you can have a selector like:
[month] [day] [year] with <select> HTML tags in your page very easily, besides of the order facilities.
what do you think?
---
(It was a mystery for me the lenght of the super thread "Trip Report PHP". Not any more)
just like you did when you pulled them out inside the date function. Then when you pull them out you could skip that step and just use the result with the date function.
<select name="TSpickMonth" size="1">
<? for ($i=1;$i<=12;$i++) {?><? echo "<option value=\"$i\""; if ($i == $month) echo "selected"; echo ">" . $mtharr[$i-1] . "</option>"; } ?>
</select>
<select name="TSpickDay" size="1">
<? for ($i=1;$i<=31;$i++) {?><? echo "<option value=\"$i\""; if ($i == $day) echo " selected"; echo ">$i</option>"; } ?>
</select>
<select name="TSpickYear" size="1">
<? for ($i=2002;$i<=2010;$i++) {?><? echo "<option value=\"$i\""; if ($i == $year) echo " selected"; echo ">$i</option>"; } ?>
</select>
Here is the code I have for the trip report.
while ($row = mysql_fetch_array($result)) {
$startdate = date("F d, Y",$row['startdate']);
$enddate = date("F d, Y",$row['enddate']);
echo '<strong>',$row['triplocation'],', ',$row['state'],'</strong>';
echo '<br>';
echo $startdate;
if ($enddate!= $startdate) echo ' to ',$enddate;
echo '<br>';