tjhilder Posted April 4, 2006 Share Posted April 4, 2006 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--]idmonth[/quote]events would compose of:[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]iddateplacestatusmonth[/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. Quote Link to comment https://forums.phpfreaks.com/topic/6533-need-some-advice-on-how-to-create-an-events-page/ Share on other sites More sharing options...
fenway Posted April 4, 2006 Share Posted April 4, 2006 Not sure why you need the months table -- I assume you'll be using the actual months themsevles and not a semantic representation? Quote Link to comment https://forums.phpfreaks.com/topic/6533-need-some-advice-on-how-to-create-an-events-page/#findComment-23716 Share on other sites More sharing options...
wickning1 Posted April 4, 2006 Share Posted April 4, 2006 Does the `month` column always match the month in the `date` column? Quote Link to comment https://forums.phpfreaks.com/topic/6533-need-some-advice-on-how-to-create-an-events-page/#findComment-23796 Share on other sites More sharing options...
tjhilder Posted April 4, 2006 Author Share Posted April 4, 2006 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 tablebasicly 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 etcas 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. Quote Link to comment https://forums.phpfreaks.com/topic/6533-need-some-advice-on-how-to-create-an-events-page/#findComment-23872 Share on other sites More sharing options...
wickning1 Posted April 4, 2006 Share Posted April 4, 2006 Using this table:[code]iddateplacestatus[/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] Quote Link to comment https://forums.phpfreaks.com/topic/6533-need-some-advice-on-how-to-create-an-events-page/#findComment-24020 Share on other sites More sharing options...
tjhilder Posted April 5, 2006 Author Share Posted April 5, 2006 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] Quote Link to comment https://forums.phpfreaks.com/topic/6533-need-some-advice-on-how-to-create-an-events-page/#findComment-24031 Share on other sites More sharing options...
wickning1 Posted April 5, 2006 Share Posted April 5, 2006 Show me exactly the code you are using. Quote Link to comment https://forums.phpfreaks.com/topic/6533-need-some-advice-on-how-to-create-an-events-page/#findComment-24048 Share on other sites More sharing options...
tjhilder Posted April 6, 2006 Author Share Posted April 6, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/6533-need-some-advice-on-how-to-create-an-events-page/#findComment-24366 Share on other sites More sharing options...
wickning1 Posted April 6, 2006 Share Posted April 6, 2006 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] Quote Link to comment https://forums.phpfreaks.com/topic/6533-need-some-advice-on-how-to-create-an-events-page/#findComment-24368 Share on other sites More sharing options...
fenway Posted April 6, 2006 Share Posted April 6, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/6533-need-some-advice-on-how-to-create-an-events-page/#findComment-24381 Share on other sites More sharing options...
tjhilder Posted April 6, 2006 Author Share Posted April 6, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/6533-need-some-advice-on-how-to-create-an-events-page/#findComment-24615 Share on other sites More sharing options...
fenway Posted April 7, 2006 Share Posted April 7, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/6533-need-some-advice-on-how-to-create-an-events-page/#findComment-24675 Share on other sites More sharing options...
wickning1 Posted April 7, 2006 Share Posted April 7, 2006 That was just a general example of how to print something like that, the $want_to_start_a_new_month was a stand-in for all the $month != $thismonth and $month = $thismonth stuff. Quote Link to comment https://forums.phpfreaks.com/topic/6533-need-some-advice-on-how-to-create-an-events-page/#findComment-24716 Share on other sites More sharing options...
tjhilder Posted April 8, 2006 Author Share Posted April 8, 2006 ok so I managed to figure out how to do it. all working now, might need a little tweaking later on though.thanks for all your help! =D Quote Link to comment https://forums.phpfreaks.com/topic/6533-need-some-advice-on-how-to-create-an-events-page/#findComment-24935 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.