PHP Nubsauce Posted July 8, 2008 Share Posted July 8, 2008 Hey Guys, What I'm trying to do is only select scheduled events from the calandar for a certain month. <?php $links2 = @mysql_query("SELECT * FROM ".$mysql_pretext."_calendar "); How can I select only June? This is the data convert I use at the top of the page. } function dateconvert($date,$func) { if ($func == 1){ //insert conversion list($day, $month, $year) = split('[/.-]', $date); $date = "$year-$month-$day"; return $date; } if ($func == 2){ //output conversion list($year, $month, $day) = split('[-.]', $date); $date = "$month/$day/$year"; return $date; } } any help would be much appriciated nubsauce Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted July 8, 2008 Share Posted July 8, 2008 first you are doing sutff very poorly DO NOT SUPPRESS ERRORS WHEN ASKING QUESTIONS!!!! You query should be in the nature of <?php $q = "select * from `table`"; $r = mysql_query($q) or die(mysql_error()."<br /><br />".$q); ?> Next we need to see some structure behind your table. Quote Link to comment Share on other sites More sharing options...
PHP Nubsauce Posted July 8, 2008 Author Share Posted July 8, 2008 I don't understand how I am doing things poorly, everything works mint. I see how your query would work, but whats the problem with mine.. ??? Anyways, here is my whole query <?php $links2 = @mysql_query("SELECT * FROM ".$mysql_pretext."_calendar "); if (!$links2) { echo("Error retrieving calendar from the database!<br>Error: " . mysql_error()); exit(); } while ($link = mysql_fetch_array($links2)) { $id = $link["ID"]; $title1 = $link["title"]; $date1 = $link["date"]; $date = dateconvert($date1, 2); $dateday = date('d', strtotime($date1)); $description = $link["description"]; $shortdescription = $link["short_description"]; once again, here is my data input for Date } function dateconvert($date,$func) { if ($func == 1){ //insert conversion list($day, $month, $year) = split('[/.-]', $date); $date = "$year-$month-$day"; return $date; } if ($func == 2){ //output conversion list($year, $month, $day) = split('[-.]', $date); $date = "$month/$day/$year"; return $date; } } Month, Day, and Year are all inserted originally as raw numbers, 1 2 3 4 and so on. ??? My only issue is it pulls up all scheduled events on the calandar, rather then just the month i want to display. Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted July 8, 2008 Share Posted July 8, 2008 I don't understand how I am doing things poorly, everything works mint. I see how your query would work, but whats the problem with mine.. ??? Exactly! how can we know if there is a problem if you are suppressing it. Quote Link to comment Share on other sites More sharing options...
PHP Nubsauce Posted July 8, 2008 Author Share Posted July 8, 2008 Okay, what exactly do you need from me to help me? :-\ Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted July 8, 2008 Share Posted July 8, 2008 well I said table structure cause how do we know which field stores you dates? Also if you supress errors and u make a mistake how will you know. You can go ahead and leave it as you have it and then expect no one here to help you unless you conform. Quote Link to comment Share on other sites More sharing options...
PHP Nubsauce Posted July 8, 2008 Author Share Posted July 8, 2008 date1 and date store the date. I'm not trying to be a smart guy here but..doesen't the data convert I posted twice now tell you this? Honestly, I'm not sure. I did not write this code. Quote Link to comment Share on other sites More sharing options...
PHP Nubsauce Posted July 8, 2008 Author Share Posted July 8, 2008 up Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted July 8, 2008 Share Posted July 8, 2008 What field type are they Date, Datetime? Quote Link to comment Share on other sites More sharing options...
PHP Nubsauce Posted July 8, 2008 Author Share Posted July 8, 2008 the field type is date Quote Link to comment 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.