Jump to content

need some advice on how to create an events page


tjhilder

Recommended Posts

Hi,

basicly (this is how I think it will go) i'll have 2 tables, 'months' and 'events'

months would compose of:

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]id
month[/quote]

events would compose of:

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]id
date
place
status
month[/quote]

what I want to do is create it so that the are then sorted into tables like this

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--][month]
[date] [place] [status]
[date] [place] [status]
[date] [place] [status]

[month]
[date] [place] [status]
[date] [place] [status]
[date] [place] [status][/quote]

so that PHP would get the info from the mysql table, and then show it on the page seperated in months but same month entries where entered under that month (hope this makes sense)

if you could help me figure out how I would do this then it would help me alot. any info would be great.

thanks in advance.
Link to comment
Share on other sites

ok so basicly this is how I want it to look on the browser.

[!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]month[!--colorc--][/span][!--/colorc--] (from months table), [!--coloro:#009900--][span style=\"color:#009900\"][!--/coloro--]date/day[!--colorc--][/span][!--/colorc--], [!--coloro:#000099--][span style=\"color:#000099\"][!--/coloro--]place[!--colorc--][/span][!--/colorc--] and [!--coloro:#993399--][span style=\"color:#993399\"][!--/coloro--]status[!--colorc--][/span][!--/colorc--]

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--][!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--][April][!--colorc--][/span][!--/colorc--]
[!--coloro:#009900--][span style=\"color:#009900\"][!--/coloro--][10][!--colorc--][/span][!--/colorc--][!--coloro:#000099--][span style=\"color:#000099\"][!--/coloro--][somewhere nice][!--colorc--][/span][!--/colorc--][!--coloro:#993399--][span style=\"color:#993399\"][!--/coloro--][confirmed][!--colorc--][/span][!--/colorc--]
[!--coloro:#009900--][span style=\"color:#009900\"][!--/coloro--][12][!--colorc--][/span][!--/colorc--][!--coloro:#000099--][span style=\"color:#000099\"][!--/coloro--][somewhere else][!--colorc--][/span][!--/colorc--][!--coloro:#993399--][span style=\"color:#993399\"][!--/coloro--][unconfirmed][!--colorc--][/span][!--/colorc--]

[!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--][May][!--colorc--][/span][!--/colorc--]
[!--coloro:#009900--][span style=\"color:#009900\"][!--/coloro--][4][!--colorc--][/span][!--/colorc--][!--coloro:#000099--][span style=\"color:#000099\"][!--/coloro--][business meeting][!--colorc--][/span][!--/colorc--][!--coloro:#993399--][span style=\"color:#993399\"][!--/coloro--][confirmed][!--colorc--][/span][!--/colorc--][/quote]

but I only know how to make it so it appears like:

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--][!--coloro:#009900--][span style=\"color:#009900\"][!--/coloro--][10][!--colorc--][/span][!--/colorc--][!--coloro:#000099--][span style=\"color:#000099\"][!--/coloro--][somewhere nice][!--colorc--][/span][!--/colorc--][!--coloro:#993399--][span style=\"color:#993399\"][!--/coloro--][confirmed][!--colorc--][/span][!--/colorc--]
[!--coloro:#009900--][span style=\"color:#009900\"][!--/coloro--][12][!--colorc--][/span][!--/colorc--][!--coloro:#000099--][span style=\"color:#000099\"][!--/coloro--][somewhere else][!--colorc--][/span][!--/colorc--][!--coloro:#993399--][span style=\"color:#993399\"][!--/coloro--][unconfirmed][!--colorc--][/span][!--/colorc--]
[!--coloro:#009900--][span style=\"color:#009900\"][!--/coloro--][4][!--colorc--][/span][!--/colorc--][!--coloro:#000099--][span style=\"color:#000099\"][!--/coloro--][business meeting][!--colorc--][/span][!--/colorc--][!--coloro:#993399--][span style=\"color:#993399\"][!--/coloro--][confirmed][!--colorc--][/span][!--/colorc--][/quote]


reason for months table: well i figured doing a 'GROUP BY month' would actually only show one result of each month, i don't know if i need the months table

basicly I want to have them grouped by month but (april, may, june) then in those months, their respective entries (included where the entries have a matching month etc

as if they where to appear like a forum index would, you have your categories, then your sub categories (i hope this makes sense) if I can do it with one table then great but if I need two then I don't mind.

as regards the 'date' column I suppose calling it 'day' instead would be a better way of putting it.
Link to comment
Share on other sites

Using this table:
[code]id
date
place
status[/code]
[code]...SELECT UNIX_TIMESTAMP(date) AS udate, place, status
   FROM events ORDER BY date...
while ($row=mysql_fetch_assoc($result)) {
   $thismonth = date('F',$row['udate']);
   $thisday = date('d',$row['udate']);
   if ($month != $thismonth) {
      $month = $thismonth;
      echo "[$month]<br/>\n";
   }
   echo '['.$thisday.']['.$row['place'].']['.$row['status'].']'.
   "<br/>\n";
}[/code]
Link to comment
Share on other sites

ok so I tried that, but it made it come out like this:

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--][December]
[31][somewhere nice][confirmed]
[31][somewhere else][unconfirmed]
[31][somewhere nice][confirmed][/quote]
Link to comment
Share on other sites

ok I managed to figure out why it wasn't working, was that the UNIX_TIMESTAMP() wasn't matching the date properly.

but I have a problem with how I want it displayed. basicly I want it to show up like this:
[code]<div>
   <div>
      $month
   </div>
   <div>
      <table>
         <tr>
            <td>day</td>
            <td>place</td>
            <td>status</td>
         </tr>
         <tr>
            <td>$thisday</td>
            <td>$row['place']</td>
            <td>$row['status']</td>
         </tr>
      </table>
   </div>
</div>[/code]

can get it to display all but the last bit properly:

[code]
      </table>
   </div>
</div>[/code]

any suggestions? that last bit needs to go after all the entries for that month have been displayed.
Link to comment
Share on other sites

It goes at the top of the loop, but put in a check so it doesn't put it in on the first time through the loop.

[code]$firsttime = TRUE;
while (...) {
    if (!$firsttime && $want_to_start_a_new_month) { echo '</table></div></div>'; }
    $firsttime = FALSE;
    ...
}[/code]
Link to comment
Share on other sites

For the record, the "correct" way to not have to keep track of all of these opens/closes is to simply push onto an array, and then iterate though it, opening before and closing after, only if the array exists. I always gather first, then output second.
Link to comment
Share on other sites

to [b]wickning1[/b], ok so I'm not sure what i'm doing wrong but I put the code into a txt file so you could see all of it and maybe figure out why it's not displaying. (</table></div></div> doesn't show up on any with the code you posted for me)

[link deleted by author]

and how it results on the source code:

[link deleted by author]

what is $want_to_start_a_new_month supposed to do?

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]It goes at the top of the loop, but put in a check so it doesn't put it in on the first time through the loop.[/quote]

shouldn't that be so that it doesn't display it until it reaches the end of how many results for each month? as if theres more then 2 results, it's going to miss the first, and put it on say the 2nd and the 3rd and so on...

------

[b]fenway[/b], could you show me a small example of what you're refering to? :)

--
TJ
Link to comment
Share on other sites

I'm not very familiar with PHP syntax; but the idea is that for each table cell/row/whatever, you're doing the same thing as you iterate though the results, so there's no difference between outputting right away or adding to an array.

Then, with that array in hand, you can open your container (e.g. a TR for a TD array) and close it at the end, without have to keep track of if i==0 or i==length-1, and so on.
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.