popcop Posted August 1, 2011 Share Posted August 1, 2011 Currently im pulling all of the data from the database and displaying it on the page but i want to be able to split it up and display it depending on the date. I want to be able to click on the january button for example and it will display all the data stored in the database with a january date. Hopefully someone can help heres my code that im using : <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link type="text/css" rel="stylesheet" href="css/master.css" /> <link rel="Stylesheet" type="text/css" href="css/counter.css"></link> <script language="Javascript" type="text/javascript" src="js/jquery-1.4.1.js"></script> <script language="Javascript" type="text/javascript" src="js/jquery.lwtCountdown-1.0.js"></script> <script language="Javascript" type="text/javascript" src="js/misc.js"></script> <title>Untitled Document</title> </head> <body> <div id="container"> <div id="topbar"></div><!-- close topbar --> <div id="main-body"> <div id="toppanel"> <img src="images/can-you-guess-small.png" width="458" height="102" alt="can you guess" /> <br/><br/><br/><br/> <table width="350" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="170" valign="top"> </td> <td width="144" valign="top"><img src="images/share-twitter-small.png" width="116" height="12" alt="share on twitter" style="margin-bottom:5px;"><br/> </td> <td width="36" valign="top"><g:plusone size="medium"></g:plusone></td> </tr> </table> </div><!-- close toppanel --> <div id="leftsection"> <div id="buttons"> <img src="images/check-predictions-header.png" width="291" height="39" style="margin-bottom:5px;" /> <table width="291" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="28" align="left" valign="top"><img src="images/august-2011.png" width="143" height="23" alt="August 2011" /></td> <td height="28" align="right" valign="top"><img src="images/september-2011.png" width="143" height="23" alt="September 2011" /></td> </tr> <tr> <td height="28" align="left" valign="top"><img src="images/october-2011.png" width="143" height="23" alt="October 2011" /></td> <td height="28" align="right" valign="top"><img src="images/november-2011.png" width="143" height="23" alt="November 2011" /></td> </tr> <tr> <td height="28" align="left" valign="top"><img src="images/december-2011.png" width="143" height="23" alt="December 2011" /></td> <td height="28" align="right" valign="top"><img src="images/january-2012.png" width="143" height="23" alt="January 2012" /></td> </tr> <tr> <td height="28" align="left" valign="top"><img src="images/february-2012.png" width="143" height="23" alt="February 2012" /></td> <td height="28" align="right" valign="top"><img src="images/march-2012.png" width="143" height="23" alt="March 2012" /></td> </tr> <tr> <td height="28" align="left" valign="top"><img src="images/april-2012.png" width="143" height="23" alt="April 2012" /></td> <td height="28" align="right" valign="top"><img src="images/may-2012.png" width="143" height="23" alt="May 2012" /></td> </tr> </table> </div><!-- close buttons --> <div id="countdown"> <span class="countheader">Days left of Season 2011 - 2012</span> <!-- Countdown dashboard start --> <div id="countdown_dashboard"> <div class="dash weeks_dash"> <div class="digit">0</div> <div class="digit">0</div> </div> <div class="dash days_dash"> <div class="digit">0</div> <div class="digit">0</div> </div> <div class="dash hours_dash"> <div class="digit">0</div> <div class="digit">0</div> </div> <div class="dash minutes_dash"> <div class="digit">0</div> <div class="digit">0</div> </div> <div class="dash seconds_dash"> <div class="digit">0</div> <div class="digit">0</div> </div> <br/> <table class="counter-text" width="270" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="54">Weeks</td> <td width="54">Days</td> <td width="54">Hours</td> <td width="54">Minutes</td> <td width="54">Seconds</td> </tr> </table> </div> <script language="javascript" type="text/javascript"> jQuery(document).ready(function() { $('#countdown_dashboard').countDown({ targetDate: { 'day': 15, 'month': 6, 'year': 2012, 'hour': 12, 'min': 0, 'sec': 0 } }); $('#email_field').focus(email_focus).blur(email_blur); $('#subscribe_form').bind('submit', function() { return false; }); }); </script> </div><!-- close countdown --> <?php $con = mysql_connect("localhost", "user", "pass"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("database", $con); $result = mysql_query("SELECT * FROM tablename"); $num_rows = mysql_num_rows($result); echo "So far only ", $num_rows, " have guessed " ; ?> </div><!-- close leftsection --> <div id="rightsection"> <span class="months">September 2011</span> <br/><br/> <?php $con = mysql_connect("localhost", "user", "pass"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("database", $con); $result = mysql_query("SELECT * FROM tablename ORDER BY date"); $num_rows = mysql_num_rows($result); echo "<table border='0' cellspacing='0'>"; while($row = mysql_fetch_array($result)) { $i++; if($i%2==0) $class="cell1"; else $class="cell2"; echo "<tr class='$class'>"; echo "<td>".$row["firstname"]." ".$row["lastname"]." thinks that it will happen on <span class=datecolor>".$row["date"]."</span></td>"; echo "</tr>"; } echo "</table>"; mysql_close($con); ?> </div><!-- close rightsection --> <div class="clear"></div> </div><!-- close home --> </div><!-- close container --> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/243464-displaying-data-depending-on-date/ Share on other sites More sharing options...
popcop Posted August 1, 2011 Author Share Posted August 1, 2011 anyone? Quote Link to comment https://forums.phpfreaks.com/topic/243464-displaying-data-depending-on-date/#findComment-1250238 Share on other sites More sharing options...
Drummin Posted August 1, 2011 Share Posted August 1, 2011 Looks like you've been posting this code around several sites, i.e. Dev Shed, Letshare.it. I found this by searching how to get the result of your jQuery date info so it can be converted to a php variable $date. As I don't know jQuery you'll have to find that on your own. Quote Link to comment https://forums.phpfreaks.com/topic/243464-displaying-data-depending-on-date/#findComment-1250252 Share on other sites More sharing options...
voip03 Posted August 1, 2011 Share Posted August 1, 2011 select date from table where month = jan order by date Quote Link to comment https://forums.phpfreaks.com/topic/243464-displaying-data-depending-on-date/#findComment-1250253 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.