Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Easy problem displaying date formats... please help :(

ecmotoecmoto Posts: 1Member
[b][red]This message was edited by ecmoto at 2004-5-2 14:13:25[/red][/b][hr]
URL: http://www.ecmoto.com/events/
-----------------------------------------------------------------------------
We are having trouble figuring out how exactly to code this page to display the following information.
ECMOTO is a templated site; we have included all corresponding code which is used to build this page.
The code that is included is what is currently running on the site. Any links, tips, articles, suggestions, constructive critisim, etc. would be greatly appreciated.
Thank you in advance.
And please excuse our coding ability, this site was/still is our learning tool for php.
I'm sure there is such an easy solution to this problem.
-----------------------------------------------------------------------------
How we would like the page to work:

an event that runs from 05.13.04 thru 05.18.04
- timestamp: 040513040518
- Displays 05.13-18.04
- Displayed on the site till midnight 05.18.04

an event that occurs on 05.13.04
- timestamp: 040513000000
- Displays 05.13.04
- Displayed on the site till midnight 05.13.04
-----------------------------------------------------------------------------
Current Code: - http://www.ecmoto.com/events/index.php
-----------------------------------------------------------------------------
<?php

if(!isset($_GET['page']))
{
$pages = 1;
}
else
{
$pages = $_GET['page'];
}

$max_results = 50;
$from = (($pages * $max_results) - $max_results);

$sql = "SELECT event_id, featured, title, DATE_FORMAT( date, '%m.%d.%Y' ) AS date, city, states.abbv as state FROM events LEFT JOIN states ON states.state_id = events.state WHERE date >= CURRENT_DATE ORDER BY events.date ASC LIMIT $from, $max_results";
$ret = db_query($sql);

if(@mysql_num_rows($ret))
{
while ($row = mysql_fetch_array($ret))
{
{
$data['EVENT_ID'] = $row['event_id'];
$data['SM_IMG'] = $row['sm_img'];
$data['TITLE'] = $row['title'];
$data['DATE'] = $row['date'];
$data['CITY'] = $row['city'];
$data['STATE'] = $row['state'];
$data['EVENTS'] = user_counts('events');
$color1 = "white";
$color12 = "whiteleft";
$color2 = "blue";
$color22 = "blueleft";
$row_color = ($row_count % 2) ? $color1 : $color2;

if($row_color == $color1)
{
$data['COLOR1'] = $color2;
$data['COLOR2'] = $color22;
} else
{
$data['COLOR1'] = $color1;
$data['COLOR2'] = $color12;
}

$row_count++;


}

$fevents_rows .= template('/events/index/fevent_row.tpl', $data, 1);
}
}
$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM events"),0);
$total_pages = ceil($total_results / $max_results);
$pagenumbers .= "Result pages: [ ";

for($i = 1; $i <= $total_pages; $i++)
{
if(($pages) == $i)
{
$pagenumbers .= "<font face="Verdana, Arial, sans-serif" size="1" color="#7192C0">$i ";
}
else
{
$pagenumbers .= "$i ";
}
}

$pagenumbers .= "]";
$cent = template('/events/index/events_main.tpl', "F_ROWS", $fevents_rows, "PAGENUMBERS", $pagenumbers, "EVENTS", user_counts("events"), 1);

$t_array["CENTRAL_CONTENT"] = $cent;

template("/main.tpl", $t_array);

?>

-----------------------------------------------------------------------------
Code Explanation / Includes / Database Sructure:
-----------------------------------------------------------------------------
------------------------------------------------------------------------
the "fevent_row.tpl" contains :



{TITLE}
{DATE}
{CITY}
{STATE}

------------------------------------------------------------------------
the "events_main.tpl" contains :
















 events.stats








Total events:

{EVENTS}





image



























{F_ROWS}

{PAGENUMBERS}


[submit event]
 














events.detail

Date

City

State


------------------------------------------------------------------------
the "main.tpl" contains :

the site design

- $t_array["CENTRAL_CONTENT"] = $cent;
- all information contained within the main site template is passed to the "CENTRAL CONTENT" variable and is displayed accordingly.
------------------------------------------------------------------------
Database structure for fields used in sql statement :

Field Type Attributes Null Default
event_id int(10) UNSIGNED No auto_increment
featured int(1) UNSIGNED Yes 1
title varchar(255) No
date timestamp(12) Yes NULL
city varchar(100) No
state int(10) UNSIGNED No 0
-----------------------------------------------------------------------------


Sign In or Register to comment.